Skip to content

Commit 34f130a

Browse files
authored
Merge branch 'master' into port-MASTG-TEST-0033
2 parents 37cdb48 + 5a3e46e commit 34f130a

File tree

179 files changed

+2940
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+2940
-198
lines changed

.github/instructions/mastg-best-practice.instructions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Scope and relationship to Knowledge:
1414
- Best Practices are prescriptive: they state what to do and why from a security perspective.
1515
- Keep background explanations minimal; for conceptual background on OS features, link to Knowledge pages under `knowledge/`.
1616

17+
Relationship to Tests and Knowledge (nuance):
18+
19+
- Tests (MASTG-TEST) describe the issue and "what can go wrong", then show how to detect it.
20+
- Knowledge (MASTG-KNOW) describes the feature/API neutrally (no "what can go wrong").
21+
- Best Practices (MASTG-BEST) explains how to prevent or mitigate the issue the tests detect.
22+
1723
### Markdown: Metadata
1824

1925
Include a YAML front matter block with the following fields:
@@ -27,6 +33,7 @@ Optional metadata:
2733
- alias: URL-friendly slug (lowercase, hyphen-separated) used for navigation.
2834
- status: draft, placeholder, deprecated.
2935
- note: Short free-form note.
36+
- knowledge: One or more related Knowledge pages (`MASTG-KNOW-####`) for neutral background and API reference.
3037
- available_since: Minimum platform version/API level where this recommendation applies (Android: integer API level; iOS: release version, for example `13`).
3138
- deprecated_since: Last applicable platform/API level.
3239

@@ -38,6 +45,7 @@ title: Preventing Screenshots and Screen Recording
3845
alias: preventing-screenshots-and-screen-recording
3946
id: MASTG-BEST-0014
4047
platform: android
48+
knowledge: [MASTG-KNOW-0105, MASTG-KNOW-0106, MASTG-KNOW-0107]
4149
---
4250
```
4351

.github/instructions/mastg-demo.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ The rule has identified some instances in the code file where a non-random sourc
187187

188188
#### Evaluation
189189

190-
A concise explanation of how you applied the test’s Evaluation section to this demo. If lines are present in the observation, explain each relevant line.
190+
A concise explanation of how you applied the test’s "Evaluation" section to this demo. If lines are present in the observation, explain each relevant line.
191191

192192
Example:
193193

.github/instructions/mastg-knowledge.instructions.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
## Knowledge Articles
22

3-
Authoring standards for the Knowledge articles under `knowledge/`. Knowledge pages explain Android or iOS features and concepts that tests and techniques rely on. They are descriptive, not prescriptive: do not include security recommendations here. Best practices belong in `best-practices/`.
3+
Authoring standards for the Knowledge articles under `knowledge/`.
4+
5+
Knowledge pages explain Android or iOS features and concepts that tests and techniques rely on.
6+
7+
Scope boundaries (this is important for consistency across the project):
8+
9+
- Knowledge (MASTG-KNOW) is descriptive: what the thing is, what it does, how it works, and what APIs/configuration knobs exist.
10+
- Tests (MASTG-TEST) are issue-focused: what can go wrong with that thing in apps, and how to detect it.
11+
- Best Practices (MASTG-BEST) are prescriptive: how to prevent or fix the issues that tests look for.
12+
13+
Because of this separation, do not include "what can go wrong", threat scenarios, failure criteria, or remediation advice in Knowledge pages.
14+
15+
Avoid language and structures that imply security testing or remediation, for example:
16+
17+
- "attackers can …", "this is insecure …", "this is vulnerable …"
18+
- "the test fails if …", "to prevent this …", "you should/shouldn’t …"
419

520
Locations and taxonomy:
621

@@ -53,7 +68,7 @@ Keep content authoritative, concise, and platform-focused. Avoid duplicating OS
5368
Considerations for writing the content:
5469

5570
- Define the concept and its scope. Relate to OS components, APIs, or security model elements.
56-
- Explain typical security-relevant behaviors or implications of the feature without necessarily recommending mitigations (that's for "best practices").
71+
- Explain behavior and implications that are relevant to security testing without framing them as "risks" or "attacks". (Tests cover "what can go wrong"; Best Practices cover "what to do about it".)
5772
- Include specific API names, version nuances, storage locations, and configuration knobs. Try to avoid code samples. Instead, refer to the existing MASTG-DEMO code files. If you include them, keep them short and explanatory.
5873
- Use references from official docs and standards. Avoid non-authoritative sources.
5974
- In body text, reference internal MAS identifiers with a leading `@` (for example, @MASTG-KNOW-0001, @MASTG-TEST-0204, @MASTG-TECH-0014, @MASTG-TOOL-0031, MASWE-0089).
@@ -70,7 +85,7 @@ Considerations for writing the content:
7085
- Cross-category content: If a topic spans two MASVS categories, choose the best fit and reference the other in the body; avoid duplicate pages.
7186
- Generic vs platform: Concepts that are identical across platforms should be split into platform folders if platform detail matters; otherwise, place details where they differ and keep overviews succinct.
7287
- Where to place recommendations: Keep all prescriptive advice (do/don't, secure configuration values, mitigations) in Best Practices pages under `best-practices/`, and link them from the "Related" section.
73-
- When writing tests, techniques, or tools, always try to link to a knowledge article or create one if it's missing.
88+
- When writing tests, techniques, or tools, always try to link to a Knowledge article (and create one if it's missing). Tests should also link to Knowledge by using the `@MASTG-KNOW-xxxx` notation to make the relationship explicit.
7489

7590
## Deprecation
7691

.github/instructions/mastg-mitmproxy-scripts.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This guide defines how to write and use mitmproxy scripts in MASTG demos. Script
44

55
### Scope and terminology
66

7-
- mitmproxy scripts refers to Python addons for mitmproxy/mitmdump written against the mitmproxy scripting API.
7+
- "mitmproxy scripts" refers to Python addons for mitmproxy/mitmdump written against the mitmproxy scripting API.
88
- Tools background (installation, proxy setup, certificates) lives in @MASTG-TOOL-0097 (mitmproxy). Do not duplicate setup steps here—link to the Tools page.
99
- We use the command-line runner `mitmdump` in demos for reproducibility; `mitmweb` and the interactive `mitmproxy` UI are fine for exploration but not for demo automation.
1010

.github/instructions/mastg-r2-scripts.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This guide defines how to write and use radare2 scripts in MASTG demos. Scripts
44

55
### Scope and terminology
66

7-
- r2 scripts refers to radare2 command files executed with `-i <file>`.
7+
- "r2 scripts" refers to radare2 command files executed with `-i <file>`.
88
- The repo uses `.r2` as the primary extension (for example, `cchash.r2`); variations like `.jr2` are not used in this repository.
99
- Tools background lives under @MASTG-TOOL-0073 (radare2) and @MASTG-TOOL-0129 (rabin2). Do not duplicate setup or installation steps—link to Tools pages.
1010

.github/instructions/mastg-test.instructions.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Example tests for reference:
2323
Notes:
2424

2525
- Tests with `platform: network` are still organized under the OS folder that the MASVS category belongs to (for example, Android network tests live under `tests-beta/android/MASVS-NETWORK/`).
26+
- Old tests under `tests/` do not follow these new guidelines. We are currently working to deprecate all of them in favor of these new approach.
2627

2728
Each test has two parts: the [Markdown metadata](#markdown-metadata) (YAML `front matter`) and the [Markdown body](#markdown-body).
2829

@@ -40,16 +41,18 @@ Follow a consistent style across all test titles.
4041

4142
**Conventions**
4243

43-
- Static: References to… (semgrep/r2)
44-
- Dynamic: Runtime Use … (frida)
44+
- Static: "References to…" (semgrep/r2)
45+
- Dynamic: "Runtime Use …" (frida)
4546

4647
Exceptions may apply where "Runtime ..." feels forced, for example, tests using adb, local backups, or filesystem snapshots.
4748

4849
#### platform
4950

50-
The mobile platform. One of the following: iOS, Android, or network.
51+
The mobile platform. One of the following:
5152

52-
- Use network for platform-agnostic traffic analysis tests where the checks are performed purely on captured/observed traffic (often paired with type: [network]).
53+
- `android`
54+
- `ios`
55+
- `network`: for platform-agnostic traffic analysis tests where the checks are performed purely on captured/observed traffic (often paired with `type: [network]`).
5356

5457
#### id
5558

@@ -88,22 +91,16 @@ type: [dynamic, manual]
8891

8992
#### best-practices
9093

91-
Reference platform-specific mitigations or best practices. Automation generates a Mitigations section.
94+
Reference platform-specific mitigations or best practices. Automation generates a "Mitigations" section.
9295

93-
New best practice files can be added under [best-practices/](https://github.com/OWASP/owasp-mastg/tree/master/best-practices).
96+
Reference the related `best-practices/` pages for background using their ID. Create the pages if they don't exist yet.
9497

9598
Example:
9699

97100
```md
98101
best-practices: [MASTG-BEST-0001]
99102
```
100103

101-
This links to https://mas.owasp.org/MASTG/best-practices/MASTG-BEST-0001/
102-
103-
Notes:
104-
105-
- If no applicable best practices exist yet, you can omit the field or set an empty list: `best-practices: []`.
106-
107104
#### prerequisites
108105

109106
List the conditions that must be known or available before running or evaluating the test. These items capture internal context that only the developer or the organization can provide. Existing files are in the `prerequisites/` folder. Create new ones when needed.
@@ -126,8 +123,8 @@ prerequisites:
126123

127124
#### profiles
128125

129-
Specify the MASVS profiles to which the test applies. Valid values: L1, L2, P, R.
130-
The profiles are described in [MAS Testing Profiles Guide]( https://docs.google.com/document/d/1paz7dxKXHzAC9MN7Mnln1JiZwBNyg7Gs364AJ6KudEs/edit?tab=t.0#heading=h.il6q80u4fm3n)
126+
Specify the MAS profiles to which the test applies. Valid values: L1, L2, P, R.
127+
The profiles are described in [MAS Testing Profiles Guide](Document/0x03b-Testing-Profiles.md)
131128

132129
- L1 denotes Essential Security.
133130
- L2 denotes Advanced Security.
@@ -140,6 +137,16 @@ Example:
140137
profiles: [L1, L2, P]
141138
```
142139

140+
#### knowledge
141+
142+
Reference the related `knowledge/` pages for background using their ID. Create the pages if they don't exist yet.
143+
144+
Example:
145+
146+
```md
147+
knowledge: [MASTG-KNOW-0013]
148+
```
149+
143150
#### optional fields
144151

145152
Include these if relevant:
@@ -158,7 +165,22 @@ Notes:
158165

159166
#### Overview
160167

161-
The overview is platform-specific and extends the weakness overview with details on the area tested. It may mention specific APIs and features.
168+
The overview is platform-specific and extends the weakness overview with details on the area tested (the Knowledge items from the `knowledge` in the metadata).
169+
170+
Very important: the overview must be phrased like an issue.
171+
172+
- Describe the relevant platform feature/API from the perspective of "what can go wrong" (risk, failure mode, exposure).
173+
- Make it clear why the test exists: what the tester is trying to detect and why that matters.
174+
175+
Do not repeat the weakness description here. Focus on the specific issue the test is checking for on the given platform.
176+
177+
Good patterns for issue framing:
178+
179+
- "If the app uses/implements/configures X, Y can happen …"
180+
- "This can lead to … (exposure, bypass, integrity failure, privacy leak) …"
181+
- "This test checks/verifies whether the app …"
182+
183+
Do not write the overview like a neutral platform description. Neutral/descriptive explanations belong in `knowledge/`.
162184

163185
Example:
164186

@@ -198,7 +220,7 @@ Notes:
198220

199221
The output you get after executing all steps. It serves as evidence.
200222

201-
It MUST start with The output should contain ....
223+
It MUST start with "The output should contain ...".
202224

203225
Example:
204226

@@ -212,7 +234,7 @@ The output should contain a list of locations where insecure random APIs are use
212234

213235
Using the observation as input, describe how to evaluate it. State explicitly what makes the test fail.
214236

215-
It MUST start with The test case fails if ....
237+
It MUST start with "The test case fails if ...".
216238

217239
Example:
218240

@@ -221,3 +243,5 @@ Example:
221243

222244
The test case fails if you can find random numbers generated using those APIs that are used in security-relevant contexts.
223245
```
246+
247+
IMPORTANT: Do not include remediation advice or best practices in the evaluation section. Remediation belongs in `best-practices/` and must be linked in the test metadata `best-practices`. If it does not exist yet, create it.

.github/instructions/porting-mastg-v1-tests-to-v2.instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ Review existing content and **UPDATE** it. Especially references to Android/iOS
105105

106106
#### Best practices linkage
107107

108-
Best practices are platform-specific and can be linked in the test metadata. Our automation creates a Mitigations section automatically.
108+
Best practices are platform-specific and must be linked in the test metadata. Our automation creates a "Mitigations" section automatically.
109109

110110
1. Check if a best practice already exists in `best-practices/` folder
111111
2. If it doesn’t exist yet, create it new in `best-practices/` using the next available ID.
112-
3. Add a reference to the best practices with @MASTG-BEST-xxxx
112+
3. Add a reference to the best practices in the test YAML front matter, for example `best-practices: [MASTG-BEST-0023]`.
113113

114114
#### Deprecating V1 tests
115115

.github/workflows/docgenerator.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
- uses: actions/setup-python@v5
2626
with:
2727
python-version: 3.x
28+
- name: Install system dependencies
29+
run: sudo apt-get update && sudo apt-get install -y libxml2-dev libxslt1-dev
2830
- name: Install dependencies
2931
run: pip install -r src/scripts/requirements.txt
3032

best-practices/MASTG-BEST-0001.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Use Secure Random Number Generator APIs
33
alias: android-use-secure-random
44
id: MASTG-BEST-0001
55
platform: android
6+
knowledge: [MASTG-KNOW-0013]
67
---
78

89
Use a cryptographically secure pseudorandom number generator as provided by the platform or programming language you are using.

best-practices/MASTG-BEST-0002.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Remove Logging Code
33
alias: remove-logging-code
44
id: MASTG-BEST-0002
55
platform: android
6+
knowledge: [MASTG-KNOW-0049]
67
---
78

89
Ideally, a release build shouldn't use any logging functions, making it easier to assess sensitive data exposure.

0 commit comments

Comments
 (0)