Add MASTG-TEST for Sensitive Data Stored Unencrypted via Java File APIs in the App Sandbox - #3796
Add MASTG-TEST for Sensitive Data Stored Unencrypted via Java File APIs in the App Sandbox#3796cpholguera with Copilot wants to merge 16 commits into
Conversation
…ASTG-DEMO-0x01, best practice MASTG-BEST-0x01, and SAST rule Agent-Logs-Url: https://github.com/OWASP/mastg/sessions/de814690-38e2-4768-b3c3-04c79a7f40a6 Co-authored-by: cpholguera <29175115+cpholguera@users.noreply.github.com>
…asing Agent-Logs-Url: https://github.com/OWASP/mastg/sessions/de814690-38e2-4768-b3c3-04c79a7f40a6 Co-authored-by: cpholguera <29175115+cpholguera@users.noreply.github.com>
|
@copilot ensure you follow the relevant .github/instructions and keep the static and dynamic tests separate, check other examples in the repo. Sometimes we create one and then in the other we say that it's the dynamic counterpart (and shortly highlight the special thing about the static or the dynamic as we do in some tests already). Do the same for the demos, you can say that one's the static and the other one is the dynamic counterpart but will use the same code sample with ../MASTG-DEMO-... |
…o into static (semgrep) and dynamic (Frooky) demos Agent-Logs-Url: https://github.com/OWASP/mastg/sessions/f6f8bdea-a503-4d48-a8b7-8ef5c67b7366 Co-authored-by: cpholguera <29175115+cpholguera@users.noreply.github.com>
… semgrep output Agent-Logs-Url: https://github.com/OWASP/mastg/sessions/f6f8bdea-a503-4d48-a8b7-8ef5c67b7366 Co-authored-by: cpholguera <29175115+cpholguera@users.noreply.github.com>
Done in commit Tests:
Demos:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Closes #3795
No test existed specifically targeting Java File APIs (
openFileOutput,FileOutputStream,FileWriter) for unencrypted sensitive data writes to the Android app sandbox — only the generic filesystem-snapshot test (MASTG-TEST-0207) covered this area indirectly.New artifacts (fake IDs, to be assigned at merge)
MASTG-TEST-0x01(tests-beta/android/MASVS-STORAGE/) — Static test forMASWE-0006; uses semgrep to findopenFileOutput/FileOutputStream/FileWritercalls in decompiled code; referencesMASTG-TEST-0x02as its dynamic counterpartMASTG-TEST-0x02(tests-beta/android/MASVS-STORAGE/) — Dynamic test forMASWE-0006; uses runtime method hooking (Frooky) to monitor File API calls and correlate with Cipher/KeyStore calls; mirrors the iOSMASTG-TEST-0300/0301pattern adapted for Android File APIsMASTG-BEST-0x01(best-practices/) — PrescribesEncryptedFile(AES-256-GCM-HKDF-4KB, KeyStore-backed) as the mitigationrules/mastg-android-unencrypted-internal-file-storage.yml— Three semgrep rules flaggingopenFileOutput,new FileOutputStream(new File(ctx.getFilesDir(), …)), andnew FileWriter(…)in decompiled JavaMASTG-DEMO-0x01(demos/android/MASVS-STORAGE/) — Static semgrep demo forMASTG-TEST-0x01; includesMastgTest.kt,MastgTest_reversed.java,run.sh, andoutput.txt(2 findings); referencesMASTG-DEMO-0x02as its dynamic counterpartMASTG-DEMO-0x02(demos/android/MASVS-STORAGE/) — Dynamic Frooky demo forMASTG-TEST-0x02; reuses the code sample fromMASTG-DEMO-0x01via{{ ../MASTG-DEMO-0x01/MastgTest.kt }}; includeshooks.json,run.sh,output.json,evaluate.sh, andevaluation.txtDemo sample highlights
MastgTest.kt(inMASTG-DEMO-0x01, shared byMASTG-DEMO-0x02) writes two files to internal storage without encryption:The static demo (
MASTG-DEMO-0x01) runs semgrep and surfaces 2 findings pointing to the exact lines. The dynamic demo (MASTG-DEMO-0x02) hooksopenFileOutputandFileOutputStream.writeat runtime;evaluation.txt(produced byevaluate.sh) shows that neither write is preceded by anyCiphercalls, confirming the data is stored unencrypted.