-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Sensitive Data Leaked via Screenshots #2917
Closed
Closed
Changes from 3 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
a795545
Add a weakness page
serek8 a1e5570
Add a test page
serek8 17d1dbc
Add a demo
serek8 3705f4d
Add Frida replacing xposed to MASTG-TEST-0023 (#2918)
JJK96 6ae941c
Update MASTG-DEMO-0008 (Title) (#2923)
cpholguera 0fe7310
Update MASTG-DEMO-0019 (Title) (#2924)
cpholguera 088860c
Refactor r2-based demos for consistency and to add AI decompiled code…
cpholguera 0a80206
Update MASTG-DEMO-0019.md (#2926)
cpholguera c494d9e
Add MASWE-PRIVACY Weaknesses (#2860)
annab-google 9c44742
added approaches
sk3l10x1ng 83de9cd
updated the content
sk3l10x1ng bcdef02
fix bold and structure
sk3l10x1ng 60bd7c0
fix space
sk3l10x1ng 21b678a
fix punctuation
sk3l10x1ng e06a44e
fix
sk3l10x1ng 60761c5
update changes
sk3l10x1ng 5c6ec40
fix puntuation
sk3l10x1ng 2a97d6e
fix
sk3l10x1ng 942a42c
fix spell
sk3l10x1ng b5a5956
updated
sk3l10x1ng 087fa67
fix spell
sk3l10x1ng b598061
added ProxyDroid, updated technique and HTTPToolkit description
sushi2k 31d5489
Update tools/network/MASTG-TOOL-0115.md
sushi2k c22f34c
fixed markdown lint errors
sushi2k 5831efa
remove extra space
sk3l10x1ng d6d23f2
fix android mappings (#2927)
cpholguera 462d0db
fix display of deprecated (#3022)
cpholguera c51d27d
Update 5_Style_Guide.md (#3025)
TheDauntless 8c87242
Improve Android backup extract commands (#2920)
JJK96 726767d
Port mastg test 0020 (by @guardsquare) (#3027)
titze c8b013c
Port MASTG-TEST-0083 (by @guardsquare) (#3029)
pascalj 9c75223
Fix quotes (#3043)
titze ae12241
Port MASTG-TEST-0081 (by @guardsquare) (#3034)
pascalj 6b1b9f4
Port MASTG-TEST-0013 (by @guardsquare) (#3033)
nmsa b92a35f
Update MASWE-0002.md (#3050)
cpholguera 2108112
Port MASTG-TEST-0001 (by @guardsquare) (#3040)
serek8 aa13eb0
blutter tool added (by @appknox) (#2881)
ScreaMy7 9db304c
Port MASTG test 0044 (by @guardsquare) (#3049)
titze 79d1079
Update MASWE-0116.md (#3057)
cpholguera fe05fd7
Update MASWE-0002.md (#3060)
cpholguera 7b53760
Fix typo in title name (#3058)
TheDauntless 25aa2b6
Port MASTG test 0038 (by @guardsquare) (#3044)
titze 725e012
Update MASTG-DEMO-0019.md (#3065)
cpholguera 6cbd2e7
Update isExcludedFromBackup.r2 (#3066)
cpholguera 83fbd81
Update isExcludedFromBackup.r2 (#3067)
cpholguera 6479fef
Update MASWE-0116.md (#3068)
tinyboxvk 0dcb253
Dont depend on system's printf for the r2 scripts (#3070)
trufae 8869591
Fix images paths in Update structure_masvs.sh (#3071)
cpholguera f6a98d0
Port MASTG test 0039 (by @guardsquare) (#3042)
titze c374b63
fix IDs (#3072)
cpholguera ca779ea
Port MASTG test 0087 (by @guardsquare) (#3056)
titze 768dd1b
fix IDs (#3075)
cpholguera abef598
Port MASTG-TEST-0003 (by @guardsquare) (#3059)
serek8 7f88184
Add MASTG-TEST-0231 for weak encryption modes on Android (#3079)
cpholguera 0154c87
fix ID (#3080)
cpholguera fc76830
Update MASTG-TEST-0221.md evaluation
cpholguera 8147c77
Add MASTG Mitigations support (#3081)
cpholguera e0c10e1
rename mitigations to best-practices (#3085)
cpholguera 01d83c8
fix title (#3086)
cpholguera 6c014cf
Port MASTG test 0019 (by @guardsquare) (#3030)
titze 8034418
Added tool Apkleaks (by @appknox) (#3052)
jeel38 de04e7e
Update MASTG-TEST-0079.md (#3083)
kmaschke85 00eab1e
Update the list of permissions (up to API level 35) (#3087)
annab-google 734d66e
Fix continuity issue (#3088)
TheDauntless 683d229
Update MASTG-TOOL-0056 with new Keychain-Dumper tool repo (#3091)
TheDauntless 444d5ae
Add deprecation notes and status for MASTG tests (#3089)
cpholguera 01adfa9
refactor resilience best practices (#3092)
cpholguera 9324139
Update MASTG-TEST-0237.md (#3093)
cpholguera 997b7c5
updated patching IPAs (#2907)
sushi2k a382f7b
Update index and talks (#3094)
cpholguera a0931ec
Update MASTG-TECH-0063.md fix Tool ID (#3095)
cpholguera 0493a24
Update 0x02a-Frontispiece.md (#3098)
sushi2k 097c47a
Fix title
serek8 ff2064a
Add a test for iOS
serek8 f52c8ea
Add new refs for the weakness
serek8 d684a7c
Update test ID
serek8 ae3169d
Add demo
serek8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
demos/android/MASVS-PLATFORM/MASTG-DEMO-0021/MASTG-DEMO-0021.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
platform: android | ||
title: Sensitive Data Leaked via Screenshots | ||
id: MASTG-DEMO-0021 | ||
code: [kotlin] | ||
test: MASTG-TEST-0216 | ||
--- | ||
|
||
### Sample | ||
|
||
The snippet below shows sample code that sets `FLAG_SECURE` on an activity that displays sensitive data. | ||
|
||
{{ MastgTest.kt }} | ||
|
||
### Steps | ||
|
||
Let's run our @MASTG-TOOL-0110 rule against the reversed java code. | ||
|
||
{{ ../../../../rules/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml }} | ||
|
||
### Observation | ||
|
||
{{ output.txt }} | ||
|
||
The rule has identified one location in the code file where an API, `FLAG_SECURE`, is used to prevent capturing the screen. | ||
|
||
### Evaluation | ||
|
||
This test succeeds because the app used an API to prevent screen recording on a screen with confidential data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.owasp.mastestapp | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.view.WindowManager.LayoutParams | ||
|
||
class MastgTest (private val context: Context){ | ||
|
||
fun mastgTest(): String { | ||
if (context is Activity) { | ||
context.window.setFlags( | ||
LayoutParams.FLAG_SECURE, | ||
LayoutParams.FLAG_SECURE | ||
) | ||
return "SUCCESS!!\n\nThe FLAG_SECURE has been set" | ||
} else { | ||
return "ERROR: Context is not an Activity" | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
demos/android/MASVS-PLATFORM/MASTG-DEMO-0021/MastgTest_reversed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.owasp.mastestapp; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import kotlin.Metadata; | ||
import kotlin.jvm.internal.Intrinsics; | ||
|
||
/* compiled from: MastgTest.kt */ | ||
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\b\u0007\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u0006\u0010\u0005\u001a\u00020\u0006R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0007"}, d2 = {"Lorg/owasp/mastestapp/MastgTest;", "", "context", "Landroid/content/Context;", "(Landroid/content/Context;)V", "mastgTest", "", "app_debug"}, k = 1, mv = {1, 9, 0}, xi = 48) | ||
/* loaded from: classes4.dex */ | ||
public final class MastgTest { | ||
public static final int $stable = 8; | ||
private final Context context; | ||
|
||
public MastgTest(Context context) { | ||
Intrinsics.checkNotNullParameter(context, "context"); | ||
this.context = context; | ||
} | ||
|
||
public final String mastgTest() { | ||
if (this.context instanceof Activity) { | ||
((Activity) this.context).getWindow().setFlags(8192, 8192); | ||
return "SUCCESS!!\n\nThe FLAG_SECURE has been set"; | ||
} | ||
return "ERROR: Context is not an Activity"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
|
||
┌────────────────┐ | ||
│ 1 Code Finding │ | ||
└────────────────┘ | ||
|
||
MastgTest_reversed.java | ||
❯❱ [1mrules.flag_secure[0m | ||
[MASVS-PLATFORM] Make sure you use this flag for all screens with sensitive data | ||
|
||
22┆ ((Activity) this.context).getWindow().setFlags(8192, 8192); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NO_COLOR=true semgrep -c ../../../../rules/mastg-android-sensitive-data-in-screenshot.yml ./MastgTest_reversed.java --text -o output.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rules: | ||
- id: flag_secure | ||
severity: WARNING | ||
languages: | ||
- java | ||
metadata: | ||
summary: This rule looks for a use of FLAG_SECURE. | ||
message: "[MASVS-PLATFORM] Make sure you use this flag for all screens with sensitive data" | ||
pattern: | | ||
$X.setFlags(8192, 8192) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: Sensitive Data Leaked via Screenshots | ||
platform: android | ||
id: MASTG-TEST-0216 | ||
type: [static] | ||
weakness: MASWE-0055 | ||
--- | ||
|
||
## Overview | ||
|
||
This test verifies whether an app uses APIs to prevent or detect screen capturing. While prevention is preferable to detection, this test ensures that the app is aware of potential screenshot issues. On Android, several APIs allow developers to detect when screenshots are taken, such as: | ||
|
||
- [FLAG_SECURE](https://developer.android.com/security/fraud-prevention/activities#flag_secure) - prevents screen recording | ||
- [DETECT_SCREEN_CAPTURE](https://developer.android.com/about/versions/14/features/screenshot-detection#implementation) - detects when a screenshot is taken | ||
|
||
## Steps | ||
|
||
1. Run a static analysis tool, such as @MASTG-TOOL-0110, on the code to identify instances of relevant API usage. | ||
|
||
## Observation | ||
|
||
The output should include a list of locations where the relevant APIs are used. | ||
|
||
## Evaluation | ||
|
||
The test case fails if you cannot find the relevant APIs on the Activities that display sensitive data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should generalize the title to cover for screenshots and screen recording.