Skip to content

Conversation

JerryTasi
Copy link
Collaborator

Detect CWE-532 in Android Application

This scenario seeks to find insertion of sensitive information into Log file in the APK file.

CWE-532: Insertion of Sensitive Information into Log File

We analyze the definition of CWE-532 and identify its characteristics.

See CWE-532 for more details.

image

Code of CWE-532 in dvba.apk

We use the dvba.apk sample to explain the vulnerability code of CWE-532.

image

CWE-532 Detection Process Using Quark Script API

image

Let's use the above APIs to show how the Quark script finds this vulnerability.

First, we use the API findMethodInAPK(samplePath, targetMethod) to locate log.d method. Then we use API methodInstance.getArguments() to get the argument that input to log.d. Finally, we use some keywords such as "token", "password", and "decrypt" to check if arguments include sensitive data. If the answer is YES, that may cause sensitive data leakage into log file.

You can use your own keywords in the keywords list to detect sensitive data.

Quark Script: CWE-532.py

image

from quark.script import findMethodInAPK

SAMPLE_PATH = "dvba.apk"
TARGET_METHOD = [
    "Landroid/util/Log;",                       # class name
    "d",                                        # method name
    "(Ljava/lang/String; Ljava/lang/String;)I"  # descriptor
]
CREDENTIAL_KEYWORDS = [
    "token",
    "decrypt",
    "password"
]

methodsFound = findMethodInAPK(SAMPLE_PATH, TARGET_METHOD)

for debugLogger in methodsFound:
    arguments = debugLogger.getArguments()

    for keyword in CREDENTIAL_KEYWORDS:
        if keyword in arguments[1]:
            print(f"CWE-532 is detected in method, {debugLogger.fullName}")

Quark Script Result

$ python CWE-532.py
CWE-532 is detected in method, Lcom/google/firebase/auth/FirebaseAuth; d (Lc/c/b/h/o;)V

Copy link

codecov bot commented Jun 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.73%. Comparing base (f326177) to head (89b72f2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #764   +/-   ##
=======================================
  Coverage   80.73%   80.73%           
=======================================
  Files          75       75           
  Lines        6265     6265           
=======================================
  Hits         5058     5058           
  Misses       1207     1207           
Flag Coverage Δ
unittests 80.73% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JerryTasi JerryTasi requested a review from sidra-asa June 18, 2025 06:49
Copy link
Collaborator

@sidra-asa sidra-asa left a comment

Choose a reason for hiding this comment

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

LGTM

@sidra-asa sidra-asa merged commit 989197a into master Jun 18, 2025
19 checks passed
@JerryTasi JerryTasi deleted the JerryTasi-patch-CWE532 branch July 1, 2025 14:20
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.

2 participants