Skip to content

Commit 5157c6d

Browse files
authored
Merge pull request #22 from vbakke/feat/descriptions-enhancement
'Context-aware output encoding' and 'Parametrization'
2 parents 95d8577 + 7624599 commit 5157c6d

File tree

4 files changed

+89
-14
lines changed

4 files changed

+89
-14
lines changed

src/assets/YAML/default/BuildAndDeployment/Build.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ Build and Deployment:
4141
comments: ""
4242
Defined build process:
4343
uuid: f6f7737f-25a9-4317-8de2-09bf59f29b5b
44+
description: |
45+
A *build process* include more than just compiling your source code.
46+
It also includes steps such as managing (third party) dependencies,
47+
environment configuration, running the unit tests, etc.
48+
49+
A *defined build process* has automated these steps to ensure consistency.
50+
51+
This can be done with a Jenkinsfile, Maven, or similar tools.
4452
risk:
4553
Performing builds without a defined process is error prone; for example,
4654
as a result of incorrect security related configuration.
4755
measure:
4856
A well defined build process lowers the possibility of errors during
4957
the build process.
50-
description: |
51-
A build process can be defined in code, for example in a `Jenkinsfile`.
5258
difficultyOfImplementation:
5359
knowledge: 2
5460
time: 3

src/assets/YAML/default/Implementation/ApplicationHardening.yaml

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,78 @@ Implementation:
5050
- Hardening is not explicitly covered by ISO 27001 - too specific
5151
- 8.22
5252
comments: ""
53-
Contextualized Encoding:
53+
Context-aware output encoding:
5454
uuid: e1f37abb-d848-4a3a-b3df-65e91a89dcb7
55+
description: |
56+
**Input validation** stops malicious data from entering your system. \
57+
**Output encoding** neutralizes malicious data before rendering to user, or the next system.
58+
59+
Input validation and output encoding work together. Apply both.
60+
61+
**Context-aware output encoding** encodes data differently, depending on its context. In the sample below the `{{bad_data}}` must be encoded differently, depending on its context, to render safe HTML.
62+
63+
```html
64+
<div>{{bad_data}}</div>
65+
<a href="{{bad_data}}">Click me</a>
66+
<script>var x = '{{bad_data}}';</script>
67+
<script>/** Comment {{bad_data}} */</script>
68+
```
5569
risk:
56-
The generation of interpreter directives from user-provided data poses difficulties and can introduce vulnerabilities to injection attacks.
70+
If an attacker manages to slip though your input validation, the attacker may gain control over the user session or execute arbitrary actions.
5771
measure: |
58-
Implementing contextualized encoding for the next interpreter, such as employing object-relational mapping tools
59-
or utilizing prepared statements, nearly removes the threat of injection vulnerabilities.
60-
61-
Also take into account a secure by default UI framework, which performs automatic contextual encoding of outputs with potential malicious user input (e.g. angular).
72+
* Use modern secure frameworks such as React/Angular/Vue/Svelte. The default method here renders data in a safe way.
73+
* Use established and well-maintained encoding libraries such as OWASP’s Java Encoder and Microsoft’s AntiXSS.
74+
* Implement content security policies (CSP) to restrict the types of content that can be loaded and executed.
6275
difficultyOfImplementation:
63-
knowledge: 2
76+
knowledge: 1
6477
time: 2
6578
resources: 1
6679
usefulness: 3
6780
level: 1
81+
implementation:
82+
- $ref: src/assets/YAML/default/implementations.yaml#/implementations/owasp-dom-xss-cheats
83+
- $ref: src/assets/YAML/default/implementations.yaml#/implementations/cwe-838
84+
references:
85+
samm2:
86+
- D-SR-1-A
87+
iso27001-2017:
88+
- Hardening is not explicitly covered by ISO 27001 - too specific
89+
- 13.1.3
90+
iso27001-2022:
91+
- Hardening is not explicitly covered by ISO 27001 - too specific
92+
- 8.22
93+
comments: ""
94+
Parametrization:
95+
uuid: 00e91a8a-3972-4692-8679-674ab8547486
6896
description: |
69-
Bear in mind that utilizing frameworks is a recommended approach; however, they can develop known security weaknesses over time. Diligent and regular patching is crucial.
70-
implementation: []
97+
By concatenating strings from user input to build SQL queries, an attacker can manipulate the query to do other unintentional SQL commands as well.
98+
99+
This is called *SQL injection* but the principle applies to NoSql, and anywhere that your code is building commands that will be executed.
100+
101+
Pay attention to these two lines of code. They seem similar, but behave very differently.
102+
103+
* `sql.execute("SELECT * FROM table WHERE ID = " + id);`
104+
* `sql.execute("SELECT * FROM table WHERE ID = ?", id);`
105+
The second line is parameterized. The same principle applies to other types, such as command line execution, etc.
106+
risk: |
107+
Systems vulnerable to injections may lead to data breaches, loss of data,
108+
unauthorized alteration of data, or complete database compromise or downtime.
109+
110+
This applies to SQL, NoSql, LDAP, XPath, email headers OS commands, etc.
111+
measure: |
112+
* Identify which of the types your application is using. Check that you use:
113+
* Use _parametrized queries_ (or _prepared statements_)
114+
* For database queries, you may also use:
115+
* Use _stored procedures_ ()
116+
* Use ORM (Object-Relational Mapping) tools that automatically handle input sanitization
117+
difficultyOfImplementation:
118+
knowledge: 1
119+
time: 2
120+
resources: 1
121+
usefulness: 3
122+
level: 1
123+
implementation:
124+
- $ref: src/assets/YAML/default/implementations.yaml#/implementations/owasp-parameterization-cheats
71125
references:
72126
samm2:
73127
- D-SR-1-A

src/assets/YAML/default/Implementation/InfrastructureHardening.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ Implementation:
701701
description: |
702702
Begin with the WAF in a monitoring state to understand the traffic and threats. Progressively enforce blocking actions based on intelligence gathered, ensuring minimal disruption to legitimate traffic.
703703
dependsOn:
704-
- Contextualized encoding
704+
- Context-aware output encoding
705705
implementation: []
706706
references:
707707
samm2:

src/assets/YAML/default/implementations.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ implementations:
4141
name: CWE Top 25 Most Dangerous Software Weaknesses
4242
tags: ["documentation", "threat"]
4343
url: https://cwe.mitre.org/top25/archive/2020/2020_cwe_top25.html
44+
cwe-838:
45+
uuid: ae97c9b0-308c-4dab-bff9-bf3330a897dc
46+
name: CWE-838 Inappropriate Encoding for Output Context
47+
tags: ["documentation", "cwe"]
48+
url: https://cwe.mitre.org/data/definitions/838.html
4449
docker-content-trust:
4550
uuid: ee81f93f-8230-4cfb-a132-ae4ec61cb8e6
4651
name: Docker Content Trust
@@ -161,9 +166,9 @@ implementations:
161166
name: Threagile
162167
tags: [threat-modeling]
163168
url: https://github.com/Threagile/threagile
164-
don-t-forget-evil-u:
169+
don-t-forget-evil-user-stories:
165170
uuid: bb5b8988-021b-452a-a914-bd36887b6860
166-
name: "[Don't Forget EVIL U"
171+
name: "Don't Forget EVIL User stories"
167172
tags: []
168173
url: https://www.owasp.org/index.php/Agile_Software_Development
169174
description:
@@ -430,6 +435,16 @@ implementations:
430435
name: OWASP Logging CheatSheet
431436
url: https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html
432437
tags: [logging, documentation]
438+
owasp-dom-xss-cheats:
439+
uuid: 2d61e48f-bade-4332-a383-adc50c29673a
440+
name: OWASP DOM based XSS Prevention CheatSheet
441+
url: https://cheatsheetseries.owasp.org/cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.html
442+
tags: []
443+
owasp-parameterization-cheats:
444+
uuid: d880fa0f-9dbb-454e-a003-d844fad31ab4
445+
name: OWASP Parameterization CheatSheet
446+
url: https://cheatsheetseries.owasp.org/cheatsheets/Query_Parameterization_Cheat_Sheet.html
447+
tags: []
433448
elk-stack:
434449
uuid: 38fe9d00-df8b-44b6-910d-ca0f02b5c5d3
435450
name: ELK-Stack

0 commit comments

Comments
 (0)