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

Sensitive Data Leaked via Screenshots #2917

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
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 Oct 25, 2024
a1e5570
Add a test page
serek8 Oct 25, 2024
17d1dbc
Add a demo
serek8 Oct 25, 2024
3705f4d
Add Frida replacing xposed to MASTG-TEST-0023 (#2918)
JJK96 Oct 25, 2024
6ae941c
Update MASTG-DEMO-0008 (Title) (#2923)
cpholguera Oct 28, 2024
0fe7310
Update MASTG-DEMO-0019 (Title) (#2924)
cpholguera Oct 28, 2024
088860c
Refactor r2-based demos for consistency and to add AI decompiled code…
cpholguera Oct 28, 2024
0a80206
Update MASTG-DEMO-0019.md (#2926)
cpholguera Oct 28, 2024
c494d9e
Add MASWE-PRIVACY Weaknesses (#2860)
annab-google Oct 30, 2024
9c44742
added approaches
sk3l10x1ng Oct 14, 2024
83de9cd
updated the content
sk3l10x1ng Oct 15, 2024
bcdef02
fix bold and structure
sk3l10x1ng Oct 15, 2024
60bd7c0
fix space
sk3l10x1ng Oct 15, 2024
21b678a
fix punctuation
sk3l10x1ng Oct 15, 2024
e06a44e
fix
sk3l10x1ng Oct 15, 2024
60761c5
update changes
sk3l10x1ng Oct 16, 2024
5c6ec40
fix puntuation
sk3l10x1ng Oct 16, 2024
2a97d6e
fix
sk3l10x1ng Oct 16, 2024
942a42c
fix spell
sk3l10x1ng Oct 17, 2024
b5a5956
updated
sk3l10x1ng Oct 23, 2024
087fa67
fix spell
sk3l10x1ng Oct 23, 2024
b598061
added ProxyDroid, updated technique and HTTPToolkit description
sushi2k Oct 30, 2024
31d5489
Update tools/network/MASTG-TOOL-0115.md
sushi2k Oct 30, 2024
c22f34c
fixed markdown lint errors
sushi2k Oct 30, 2024
5831efa
remove extra space
sk3l10x1ng Oct 30, 2024
d6d23f2
fix android mappings (#2927)
cpholguera Nov 2, 2024
462d0db
fix display of deprecated (#3022)
cpholguera Nov 2, 2024
c51d27d
Update 5_Style_Guide.md (#3025)
TheDauntless Nov 4, 2024
8c87242
Improve Android backup extract commands (#2920)
JJK96 Nov 4, 2024
726767d
Port mastg test 0020 (by @guardsquare) (#3027)
titze Nov 6, 2024
c8b013c
Port MASTG-TEST-0083 (by @guardsquare) (#3029)
pascalj Nov 6, 2024
9c75223
Fix quotes (#3043)
titze Nov 6, 2024
ae12241
Port MASTG-TEST-0081 (by @guardsquare) (#3034)
pascalj Nov 6, 2024
6b1b9f4
Port MASTG-TEST-0013 (by @guardsquare) (#3033)
nmsa Nov 6, 2024
b92a35f
Update MASWE-0002.md (#3050)
cpholguera Nov 7, 2024
2108112
Port MASTG-TEST-0001 (by @guardsquare) (#3040)
serek8 Nov 7, 2024
aa13eb0
blutter tool added (by @appknox) (#2881)
ScreaMy7 Nov 7, 2024
9db304c
Port MASTG test 0044 (by @guardsquare) (#3049)
titze Nov 7, 2024
79d1079
Update MASWE-0116.md (#3057)
cpholguera Nov 7, 2024
fe05fd7
Update MASWE-0002.md (#3060)
cpholguera Nov 7, 2024
7b53760
Fix typo in title name (#3058)
TheDauntless Nov 7, 2024
25aa2b6
Port MASTG test 0038 (by @guardsquare) (#3044)
titze Nov 7, 2024
725e012
Update MASTG-DEMO-0019.md (#3065)
cpholguera Nov 8, 2024
6cbd2e7
Update isExcludedFromBackup.r2 (#3066)
cpholguera Nov 8, 2024
83fbd81
Update isExcludedFromBackup.r2 (#3067)
cpholguera Nov 8, 2024
6479fef
Update MASWE-0116.md (#3068)
tinyboxvk Nov 9, 2024
0dcb253
Dont depend on system's printf for the r2 scripts (#3070)
trufae Nov 12, 2024
8869591
Fix images paths in Update structure_masvs.sh (#3071)
cpholguera Nov 13, 2024
f6a98d0
Port MASTG test 0039 (by @guardsquare) (#3042)
titze Nov 20, 2024
c374b63
fix IDs (#3072)
cpholguera Nov 20, 2024
ca779ea
Port MASTG test 0087 (by @guardsquare) (#3056)
titze Nov 26, 2024
768dd1b
fix IDs (#3075)
cpholguera Nov 26, 2024
abef598
Port MASTG-TEST-0003 (by @guardsquare) (#3059)
serek8 Nov 29, 2024
7f88184
Add MASTG-TEST-0231 for weak encryption modes on Android (#3079)
cpholguera Nov 29, 2024
0154c87
fix ID (#3080)
cpholguera Nov 30, 2024
fc76830
Update MASTG-TEST-0221.md evaluation
cpholguera Nov 29, 2024
8147c77
Add MASTG Mitigations support (#3081)
cpholguera Dec 2, 2024
e0c10e1
rename mitigations to best-practices (#3085)
cpholguera Dec 4, 2024
01d83c8
fix title (#3086)
cpholguera Dec 4, 2024
6c014cf
Port MASTG test 0019 (by @guardsquare) (#3030)
titze Dec 7, 2024
8034418
Added tool Apkleaks (by @appknox) (#3052)
jeel38 Dec 8, 2024
de04e7e
Update MASTG-TEST-0079.md (#3083)
kmaschke85 Dec 8, 2024
00eab1e
Update the list of permissions (up to API level 35) (#3087)
annab-google Dec 10, 2024
734d66e
Fix continuity issue (#3088)
TheDauntless Dec 11, 2024
683d229
Update MASTG-TOOL-0056 with new Keychain-Dumper tool repo (#3091)
TheDauntless Dec 11, 2024
444d5ae
Add deprecation notes and status for MASTG tests (#3089)
cpholguera Dec 11, 2024
01adfa9
refactor resilience best practices (#3092)
cpholguera Dec 11, 2024
9324139
Update MASTG-TEST-0237.md (#3093)
cpholguera Dec 11, 2024
997b7c5
updated patching IPAs (#2907)
sushi2k Dec 12, 2024
a382f7b
Update index and talks (#3094)
cpholguera Dec 13, 2024
a0931ec
Update MASTG-TECH-0063.md fix Tool ID (#3095)
cpholguera Dec 13, 2024
0493a24
Update 0x02a-Frontispiece.md (#3098)
sushi2k Dec 24, 2024
097c47a
Fix title
serek8 Jan 2, 2025
ff2064a
Add a test for iOS
serek8 Jan 2, 2025
f52c8ea
Add new refs for the weakness
serek8 Jan 2, 2025
d684a7c
Update test ID
serek8 Jan 2, 2025
ae3169d
Add demo
serek8 Jan 2, 2025
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
29 changes: 29 additions & 0 deletions demos/android/MASVS-PLATFORM/MASTG-DEMO-0021/MASTG-DEMO-0021.md
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.
20 changes: 20 additions & 0 deletions demos/android/MASVS-PLATFORM/MASTG-DEMO-0021/MastgTest.kt
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"
}
}
}
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";
}
}
11 changes: 11 additions & 0 deletions demos/android/MASVS-PLATFORM/MASTG-DEMO-0021/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


┌────────────────┐
│ 1 Code Finding │
└────────────────┘

MastgTest_reversed.java
❯❱ rules.flag_secure
[MASVS-PLATFORM] Make sure you use this flag for all screens with sensitive data

22┆ ((Activity) this.context).getWindow().setFlags(8192, 8192);
1 change: 1 addition & 0 deletions demos/android/MASVS-PLATFORM/MASTG-DEMO-0021/run.sh
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
10 changes: 10 additions & 0 deletions rules/mastg-android-sensitive-data-in-screenshot.yml
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)
26 changes: 26 additions & 0 deletions tests-beta/android/MASVS-PLATFORM/MASTG-TEST-0216.md
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.
20 changes: 13 additions & 7 deletions weaknesses/MASVS-PLATFORM/MASWE-0055.md
Copy link
Collaborator

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.

Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ mappings:

refs:
- https://developer.android.com/about/versions/14/features/screenshot-detection
draft:
description: no method is used to prevent specific content from being captured (e.g.
via FLAG_SECURE on Android and Secure Text Entry on iOS)
topics:
- Screenshots Not Prevented (e.g. via DETECT_SCREEN_CAPTURE on Android)
- Screenshots not deleted when backgrounding
- Auto-Generated Screenshots
status: draft

---

## Overview

Mobile platforms allow users and third-party tools to record screens, which can expose sensitive data and increase the risk of data leakage.

## Impact

- **Loss of Confidentiality**: Under certain conditions, an attacker could access sensitive data previously displayed on the screen, potentially compromising confidentiality and enabling further attacks, such as identity theft or account takeover.

## Modes of Introduction

- **Third-party apps with a permission to recording record the screen**: Third-party apps may record the screen while sensitive content is displayed.
- **Third-party apps with a permission to access the whole storage**: Third-party apps may access screenshots saved in storage after they are taken by the user or a tool.
- **External tools may record the screen**: Tools such as [scrcpy](https://github.com/Genymobile/scrcpy) and [QuickTime](https://support.apple.com/guide/quicktime-player/welcome/mac) can record the device's screen via a USB connection.
Loading