Skip to content

Port MASTG-TEST-0034: Testing Object Persistence (android) (by @appknox)#3672

Open
sk3l10x1ng wants to merge 12 commits intoOWASP:masterfrom
sk3l10x1ng:port_mastg_test_0034-1
Open

Port MASTG-TEST-0034: Testing Object Persistence (android) (by @appknox)#3672
sk3l10x1ng wants to merge 12 commits intoOWASP:masterfrom
sk3l10x1ng:port_mastg_test_0034-1

Conversation

@sk3l10x1ng
Copy link
Collaborator

@sk3l10x1ng sk3l10x1ng commented Jan 30, 2026

closes #3000

changes in PR #3418 & #3259 addressed here

@sk3l10x1ng
Copy link
Collaborator Author

@cpholguera @serek8 , please review. The request changes in #3672 are addressed here

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports the legacy Android test MASTG-TEST-0034 to a new v2 test format, deprecates the v1 test, and adds a semgrep rule + demo material intended to support the new test.

Changes:

  • Deprecates tests/android/MASVS-CODE/MASTG-TEST-0034.md and links it to a v2 replacement.
  • Adds a new v2 test file under tests-beta/android/MASVS-CODE/.
  • Adds a semgrep rule and a corresponding Android demo (sample code, reversed code, run script, and output).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/android/MASVS-CODE/MASTG-TEST-0034.md Marks the v1 test as deprecated and points to a v2 replacement.
tests-beta/android/MASVS-CODE/MASTG-TEST-0x34.md Introduces the proposed v2 test content for the port.
rules/mastg-android-object-deserialization.yml Adds a semgrep rule intended to detect object deserialization usage.
demos/android/MASVS-CODE/MASTG-DEMO-0x34/MASTG-DEMO-0x34.md Adds demo documentation describing how to run/interpret the rule.
demos/android/MASVS-CODE/MASTG-DEMO-0x34/MastgTest.kt Adds demo Kotlin sample implementing the insecure pattern.
demos/android/MASVS-CODE/MASTG-DEMO-0x34/MastgTest_reversed.java Adds reversed Java code used for static analysis in the demo.
demos/android/MASVS-CODE/MASTG-DEMO-0x34/run.sh Adds a script to run semgrep for the demo.
demos/android/MASVS-CODE/MASTG-DEMO-0x34/output.txt Adds captured semgrep output used in the demo documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +13
## Overview

If the app deserializes untrusted data without sufficient validation, it becomes vulnerable to malicious object injection. In Android, data can be passed between components via Intent objects. When an application receives a serialized object within an Intent and deserializes it using `ObjectInputStream.readObject()` without type filtering, a malicious application can send a specially crafted Intent containing a malicious serialized object. This can lead to arbitrary code execution, data tampering, privilege escalation, or denial of service depending on the available gadget chains in the application's classpath.

Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The new v2 test content focuses on untrusted object deserialization / object injection via ObjectInputStream.readObject() (e.g., from Intent extras or network input), but the deprecated v1 test "Testing Object Persistence" focuses on persistence/storage of serialized objects (Serializable/JSON/ORM) and protecting sensitive data at rest. This looks like a scope change from the PR title/issue; please align the v2 test with the v1 intent (object persistence of sensitive data) or update the PR/issue mapping accordingly.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was as agreed. Very nice that it noticed it though!!

Comment on lines 38 to 42
fun mastgTest(): String {
val user = UserManager.currentUser
val status = if (user is AdminUser && user.isAdmin) {
"PRIVILEGED ADMIN!"
} else {
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

To make the demo self-describing and easier to validate, add a short SUMMARY: comment and explicit FAIL:/PASS: annotations tied to the relevant test/rule near the vulnerable lines (this convention is used by other demos, e.g., demos/android/MASVS-CRYPTO/MASTG-DEMO-0008/MastgTest.kt). Right now the sample demonstrates the behavior but is missing those expected-outcome markers.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines 9 to 12
patterns:
- pattern:
$VAR = new java.io.ObjectInputStream(...);
$OBJ = $VAR.readObject(); No newline at end of file
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The pattern value is multi-line but isn’t using a block scalar (pattern: |/|-). Other multi-line semgrep rules in this repo do (e.g., rules/mastg-android-device-passcode-present.yml), which avoids YAML newline folding. Also, the current pattern requires the readObject() call to be directly adjacent to the ObjectInputStream construction; consider adding ... between statements so common real-world variants still match.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@serek8 serek8 self-requested a review February 10, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MASTG v1->v2 MASTG-TEST-0034: Testing Object Persistence (android)

2 participants