Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MASWE-0001, MASWE-0027, MASWE-0108] MAS Risks and Tests (PREVIEW DRAFT) #2518

Merged
merged 55 commits into from
Feb 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b65abc8
first draft
cpholguera Oct 13, 2023
2eb330e
add mitigation
cpholguera Oct 13, 2023
db1b5df
update mitigations and risks
cpholguera Oct 14, 2023
87693b9
fixes for Sensitive Data in Network Traffic
cpholguera Oct 27, 2023
844af15
add new sample tests
cpholguera Oct 27, 2023
93b3555
new structure for risks and tests
cpholguera Dec 9, 2023
79c2d4d
Add content to all risk.md files and delete unused risk files
cpholguera Dec 9, 2023
c6c9b12
remove tests folders
cpholguera Jan 5, 2024
7232276
rename mitigation files
cpholguera Jan 5, 2024
f12dcb7
remove mappings/owasp-masvs for all risks. It will be automatically g…
cpholguera Jan 5, 2024
0fdb602
remove mappings/owasp-masvs for all risks. It will be automatically g…
cpholguera Jan 9, 2024
30967a4
First draft - Risk and Test update for Android logging
sushi2k Jan 12, 2024
452a1a4
fix test aliases and add missing
cpholguera Jan 13, 2024
6a5af6b
Add secure random number generation and update insecure random usage …
cpholguera Jan 13, 2024
8ffffd0
Merge branch 'mastg-risks-and-tests' of https://github.com/OWASP/owas…
cpholguera Jan 13, 2024
a5fa9c8
Remove "Modes of Introduction" section from risk.md files
cpholguera Jan 13, 2024
25d9660
Update method tracing in Android techniques
cpholguera Jan 13, 2024
42c6b3a
Fix method trace link in test.md
cpholguera Jan 13, 2024
65348aa
Update CWE mappings in risk.md files to be a list of IDs
cpholguera Jan 13, 2024
f30bc9c
Update test type to be a list. Updated platform specific mitigations …
cpholguera Jan 13, 2024
d133445
Add prerequisites folder with 2 examples
cpholguera Jan 13, 2024
ca13fb0
Refactor insecure random API test case. Link to existing prerequisite…
cpholguera Jan 13, 2024
d93ccfd
Add content to the static analysis technique for Android apps
cpholguera Jan 13, 2024
7c1fc10
Update insecure random API link and method trace links to techniques
cpholguera Jan 13, 2024
4226549
Update insecure random number generator rule in MASVS-CRYPTO
cpholguera Jan 14, 2024
b7e5084
Update content in insecure random test examples and add SARIF. Add su…
cpholguera Jan 14, 2024
086d0b9
update with example
sushi2k Jan 15, 2024
a638776
Merge branch 'mastg-risks-and-tests' of https://github.com/OWASP/owas…
sushi2k Jan 15, 2024
40be282
Update test case
sushi2k Jan 15, 2024
6c4abef
update frida-trace
sushi2k Jan 15, 2024
c8a0a62
add example for frida-trace
sushi2k Jan 15, 2024
1263af8
updated tests according to the latest guidelines
cpholguera Jan 15, 2024
80c2d88
delete empty risk files
cpholguera Jan 15, 2024
03d4e96
fix for android-data-in-logs-semgrep
cpholguera Jan 15, 2024
ae25710
remove mstg- rules
cpholguera Jan 15, 2024
e9366b7
delete empty test files
cpholguera Jan 15, 2024
7034415
Move the test android-data-in-traffic-capture from NETWORK-1 to PRIVA…
cpholguera Jan 16, 2024
ab8ecd0
update insecure network comm risk
cpholguera Jan 19, 2024
9e95276
update current example risks
cpholguera Jan 19, 2024
3e5a694
fix other risks metadata
cpholguera Jan 19, 2024
4b03f0e
leave only 3 example risks
cpholguera Jan 19, 2024
0fe2c5c
rm initial tests
cpholguera Jan 19, 2024
c3e48f5
add privacy risk
cpholguera Jan 19, 2024
8ceb0b6
remove initial examples
cpholguera Jan 19, 2024
186d731
update privacy example
cpholguera Jan 19, 2024
9b2e9cd
update privacy example
cpholguera Jan 19, 2024
0a04b97
update example and technique
cpholguera Jan 19, 2024
689d06d
Merge branch 'master' of https://github.com/OWASP/owasp-mastg into ma…
cpholguera Jan 21, 2024
6d80dc7
Update android-data-in-logs-frida/example-1
cpholguera Jan 24, 2024
374b9ab
rm -q option
cpholguera Feb 2, 2024
05f2112
Merge branch 'master' of https://github.com/OWASP/owasp-mastg into ma…
cpholguera Feb 7, 2024
96dd1c5
add test overviews
cpholguera Feb 14, 2024
8a239b3
Update .vscode/settings.json to disable GitHub code scanning
cpholguera Feb 14, 2024
74ec6e8
Remove example-2 for logging APIs
cpholguera Feb 14, 2024
d62ff0a
fix 400 link
cpholguera Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update privacy example
cpholguera committed Jan 19, 2024
commit 186d731f93340a7fac9eea1c3847346e70505a4a
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
platform: android
title: Detecting User Name and Password in Network Traffic
title: Detecting Sensitive Data in Network Traffic
tools: [mitmproxy]
code: [kotlin]
---
@@ -27,8 +27,8 @@ The script has identified several instances in the network traffic where sensiti

Review each of the reported instances.

- The first instance is a POST request to `https://httpbin.org/post` which contains the user and password in the request body.
- The second instance is a response from `https://httpbin.org/post` which contains the user and password in the response body.
- The first instance is a POST request to `https://httpbin.org/post` which contains the sensitive data values in the request body.
- The second instance is a response from `https://httpbin.org/post` which contains the sensitive data values in the response body.

This is a dummy example, but in a real-world scenario, you should determine which of the reported instances are privacy-relevant and need to be addressed. You can use the list of sensitive data you identified in the [Identify your sensitive data](MASTG-KNOW-0001) section as a reference.

Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from mitmproxy import http

SENSITIVE_STRINGS = ["dummyPassword", "sampleUser"]
# This data would come from another file and should be defined after identifying the data that is considered sensitive for this application.
# For example by using the Google Play Store Data Safety section.
SENSITIVE_DATA = {
"precise_location_latitude": "37.7749",
"precise_location_longitude": "-122.4194",
"name": "John Doe",
"email_address": "john.doe@example.com",
"phone_number": "+11234567890",
"credit_card_number": "1234 5678 9012 3456"
}

SENSITIVE_STRINGS = SENSITIVE_DATA.values()

def contains_sensitive_data(string):
return any(sensitive in string for sensitive in SENSITIVE_STRINGS)
@@ -14,18 +25,16 @@ def process_flow(flow):

if (contains_sensitive_data(url) or
contains_sensitive_data(request_body) or
any(contains_sensitive_data(header) for header in request_headers.values()) or
any(contains_sensitive_data(header) for header in response_headers.values()) or
contains_sensitive_data(response_body)):
with open("sensitive_data.log", "a") as file:
if flow.response:
file.write(f"RESPONSE URL: {flow.request.pretty_url}\n")
file.write(f"Response Headers: {flow.response.headers}\n")
file.write(f"Response Body: {flow.response.text}\n\n")
file.write(f"RESPONSE URL: {url}\n")
file.write(f"Response Headers: {response_headers}\n")
file.write(f"Response Body: {response_body}\n\n")
else:
file.write(f"REQUEST URL: {flow.request.pretty_url}\n")
file.write(f"Request Headers: {flow.request.headers}\n")
file.write(f"Request Body: {flow.request.text}\n\n")
file.write(f"REQUEST URL: {url}\n")
file.write(f"Request Headers: {request_headers}\n")
file.write(f"Request Body: {request_body}\n\n")
def request(flow: http.HTTPFlow):
process_flow(flow)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll provide a very simple skeleton app with, say, a button and placeholders to copy and paste the samples so that everyone can test the apps with the exact same configuration.

Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
val SENSITIVE_DATA = mapOf(
"precise_location_latitude" to "37.7749",
"precise_location_longitude" to "-122.4194",
"name" to "John Doe",
"email_address" to "john.doe@example.com",
"phone_number" to "+11234567890",
"credit_card_number" to "1234 5678 9012 3456"
)

val thread = Thread {
try {
val url = URL("https://httpbin.org/post")
@@ -6,10 +15,10 @@ val thread = Thread {
httpURLConnection.doOutput = true
httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")

val user = "sampleUser"
val password = "dummyPassword"

val postData = "username=$user&password=$password"
// Creating POST data from the SENSITIVE_DATA map
val postData = SENSITIVE_DATA.map { (key, value) ->
"${URLEncoder.encode(key, "UTF-8")}=${URLEncoder.encode(value, "UTF-8")}"
}.joinToString("&")

val outputStream = BufferedOutputStream(httpURLConnection.outputStream)
val bufferedWriter = BufferedWriter(OutputStreamWriter(outputStream, "UTF-8"))
@@ -29,4 +38,4 @@ val thread = Thread {
e.printStackTrace()
}
}
thread.start()
thread.start()
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
REQUEST URL: https://httpbin.org/post
Request Headers: Headers[(b'Content-Type', b'application/x-www-form-urlencoded'), (b'User-Agent', b'Dalvik/2.1.0 (Linux; U; Android 13; sdk_gphone64_arm64 Build/TE1A.220922.021)'), (b'Host', b'httpbin.org'), (b'Connection', b'Keep-Alive'), (b'Accept-Encoding', b'gzip'), (b'Content-Length', b'42')]
Request Body: username=sampleUser&password=dummyPassword
Request Headers: Headers[(b'Content-Type', b'application/x-www-form-urlencoded'), (b'User-Agent', b'Dalvik/2.1.0 (Linux; U; Android 13; sdk_gphone64_arm64 Build/TE1A.220922.021)'), (b'Host', b'httpbin.org'), (b'Connection', b'Keep-Alive'), (b'Accept-Encoding', b'gzip'), (b'Content-Length', b'188')]
Request Body: precise_location_latitude=37.7749&precise_location_longitude=-122.4194&name=John+Doe&email_address=john.doe%40example.com&phone_number=%2B11234567890&credit_card_number=1234+5678+9012+3456

RESPONSE URL: https://httpbin.org/post
Response Headers: Headers[(b'Date', b'Tue, 16 Jan 2024 09:08:08 GMT'), (b'Content-Type', b'application/json'), (b'Content-Length', b'548'), (b'Connection', b'keep-alive'), (b'Server', b'gunicorn/19.9.0'), (b'Access-Control-Allow-Origin', b'*'), (b'Access-Control-Allow-Credentials', b'true')]
Response Headers: Headers[(b'Date', b'Fri, 19 Jan 2024 10:17:44 GMT'), (b'Content-Type', b'application/json'), (b'Content-Length', b'735'), (b'Connection', b'keep-alive'), (b'Server', b'gunicorn/19.9.0'), (b'Access-Control-Allow-Origin', b'*'), (b'Access-Control-Allow-Credentials', b'true')]
Response Body: {
"args": {},
"data": "",
"files": {},
"form": {
"password": "dummyPassword",
"username": "sampleUser"
"credit_card_number": "1234 5678 9012 3456",
"email_address": "john.doe@example.com",
"name": "John Doe",
"phone_number": "+11234567890",
"precise_location_latitude": "37.7749",
"precise_location_longitude": "-122.4194"
},
"headers": {
"Accept-Encoding": "gzip",
"Content-Length": "42",
"Content-Length": "188",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 13; sdk_gphone64_arm64 Build/TE1A.220922.021)",
"X-Amzn-Trace-Id": "Root=1-65a64778-78495e9f5d742c9b0c7a75d8"
"X-Amzn-Trace-Id": "Root=1-65aa4c48-45514c0e3782665063b14397"
},
"json": null,
"origin": "148.141.65.87",
"url": "https://httpbin.org/post"
}


}