본문으로 건너뛰기
cccskills
무료GitHub에 공개

mobile-code-quality

Detects code quality vulnerabilities in mobile apps (Android/iOS). Trigger on: SQL injection in SQLite, JavaScript injection in WebViews, intent injection, unsafe deserialization, NSKeyedUnarchiver, NSCoding, Java serialization, Parcelable, buffer overflow, JNI native code, PIE disabled, NX disabled, stack canary absent, RELRO, ARC disabled, third-party library CVE, vulnerable dependency, outdated SDK, targetSdkVersion, update enforcement missing, implicit Intent, URL loading in WebView, object persistence, memory corruption, OWASP dependency check. Covers MASVS-CODE-1/2/3/4.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md8.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Mobile Code Quality

What Is Broken and Why

Mobile code quality vulnerabilities arise from using deprecated/unsafe APIs, failing to validate input from local storage or IPC, insecure object deserialization, and shipping with exploitable native code. SQL injection via string-concatenated SQLite queries is common. WebViews that load arbitrary URLs without scheme/host validation allow navigation to attacker-controlled content. Java/Kotlin deserialization of untrusted Parcelables or ObjectInputStream can lead to type confusion and arbitrary code execution. Native code (JNI/NDK) compiled without stack canaries, PIE, or NX creates exploitable memory corruption conditions.

Key Signals

  • rawQuery("SELECT * FROM users WHERE id='" + userInput + "'") — string-concatenated SQL
  • webView.loadUrl(intent.getStringExtra("url")) — unvalidated URL load
  • ObjectInputStream.readObject() on data from Intent extras or ContentProvider
  • NSKeyedUnarchiver.unarchiveObject(with:) without class whitelist (iOS < 12)
  • Native library without PIE: checksec --file=libapp.so shows No PIE
  • Gradle implementation dependency with published CVE in OSS Index
  • targetSdkVersion below 30 — misses numerous security improvements
  • Implicit Intent used to send sensitive data: sendBroadcast(Intent("ACTION")) without package target
  • No version check / forced update mechanism — vulnerable older versions remain in production

Methodology

SQL Injection:

  1. Identify SQLite query construction in decompiled code — search for rawQuery, execSQL with + concatenation
  2. Trace input sources: Intent extras, ContentProvider queries, user input fields
  3. Test: inject ' OR '1'='1 via deep link parameter or IPC

WebView URL loading:

  1. Find all webView.loadUrl() / WKWebView.load(URLRequest) calls
  2. Trace the URL source — does it come from user input, Intent, or remote config?
  3. Inject javascript: or file:// scheme payloads

Deserialization:

  1. Search for ObjectInputStream, Parcel.readValue, NSKeyedUnarchiver in source
  2. Check if input is from untrusted source (Intent extras, network, files)
  3. Attempt to pass crafted gadget chain via Intent Parcelable extra

Binary hardening:

# Android — check native library protections
apktool d app.apk
for so in app/lib/**/*.so; do checksec --file="$so"; done

# iOS — check binary protections
otool -hv Payload/App.app/App  # check MH_PIE flag
otool -Iv Payload/App.app/App | grep stack_chk  # stack canary

Dependency scanning:

# Android — OWASP Dependency-Check
dependency-check --project "app" --scan app.apk --format HTML

# iOS — check Podfile.lock or Package.resolved for known CVEs

Payloads & Tools

# semgrep — Android SQL injection patterns
semgrep --pattern 'rawQuery($QUERY + $INPUT, $_)' --lang java android-src/
semgrep --pattern 'execSQL($QUERY + $INPUT)' --lang java android-src/

# adb — inject SQL via deep link
adb shell am start -W -a android.intent.action.VIEW \
  -d "app://search?q=' OR '1'='1" TARGET_PKG

# checksec — native library hardening
checksec --file=libapp.so
# Look for: Canary: No, NX: No, PIE: No, RELRO: No

# MobSF — automated scan
docker run -it -p 8000:8000 opensecurity/mobile-security-framework-mobsf
# Upload APK — check "Binary Analysis" and "Code Analysis" sections

# iOS — class whitelist check (correct pattern)
# Should use: NSKeyedUnarchiver.unarchivedObject(ofClass: Target.self, from: data)
# Not: NSKeyedUnarchiver.unarchiveObject(with: data)  (deprecated, no type restriction)

Bypass Techniques

  • Parcelable deserialization confusion — Android's Parcel reads type information from data; craft Parcel with type confusion to trigger unexpected code paths
  • WebView scheme confusion — intent:// URIs in WebView can launch app components on Android; file:// cross-origin reads possible with setAllowFileAccessFromFileURLs
  • Dependency CVE chaining — vulnerable transitive dependency (not direct dependency) often missed by basic scans
  • Native format string — JNI function using printf(userInput) without format string → info leak or code execution

Exploitation Scenarios

Scenario 1 — SQLite Injection via Deep Link Setup: App's search feature constructs rawQuery("SELECT * FROM notes WHERE title LIKE '" + query + "'"). Deep link passes query parameter. → Trigger: app://search?q=' UNION SELECT password FROM users --. → Impact: All user passwords extracted from local database.

Scenario 2 — WebView File Read via Intent Setup: WebViewActivity loads intent.getStringExtra("url") without validation; setAllowFileAccessFromFileURLs(true). → Trigger: Malicious app sends Intent with url=file:///data/data/TARGET/shared_prefs/auth.xml. → Impact: Victim's SharedPreferences (containing tokens) read by attacker via WebView.

Scenario 3 — Native Buffer Overflow Setup: JNI function processes image metadata with strcpy(buf, userControlledString) — no bounds check, no stack canary. → Trigger: Craft image with oversized EXIF field. → Impact: Stack smash; exploitable for code execution in native context.

False Positives

  • rawQuery with parameterized query: rawQuery("SELECT * FROM t WHERE id=?", arrayOf(id)) — safe
  • WebView loading only file:///android_asset/ or https:// with host whitelist
  • Deserialization of trusted, internally generated data with known class whitelist
  • Old targetSdkVersion in a library module that doesn't affect app runtime security features

Fix Patterns

// Android — parameterized SQLite query
db.rawQuery("SELECT * FROM notes WHERE title LIKE ?", arrayOf("%$userInput%"))
// Or use Room with @Query annotation (handles binding automatically)

// Android — WebView URL whitelist
val allowedHosts = setOf("api.target.com", "assets.target.com")
webView.webViewClient = object : WebViewClient() {
    override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
        return request.url.host !in allowedHosts  // block if not whitelisted
    }
}
// iOS — typed NSKeyedUnarchiver (safe)
guard let obj = try? NSKeyedUnarchiver.unarchivedObject(ofClass: MyModel.self, from: data) else { return }

// iOS — force update check
let storeVersion = fetchAppStoreVersion()
if currentVersion < minimumSupportedVersion { showForceUpdateDialog() }
# CMakeLists.txt — enable hardening flags for native code
target_compile_options(mylib PRIVATE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fpie)
target_link_options(mylib PRIVATE -Wl,-z,relro,-z,now -pie)

Related Skills

[[mobile-platform-interaction]] is the delivery layer for many code quality vulnerabilities — exported components and deep links are how untrusted input reaches rawQuery() and webView.loadUrl(). SQLite injection via string concatenation here is the mobile equivalent of [[sql-injection]] on the web, with identical methodology and payloads adapted for Android's rawQuery. Deserialization of Parcelable data mirrors web-side unsafe deserialization and [[xxe]] in the sense that both exploit parser trust of attacker-controlled structured input.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Exploit pervasive logical flaws in Multi-Factor Authentication (MFA/2FA) implementations to bypass the secondary authentication challenge entirely. Techniques include response manipulation, referal spoofing, token reuse, and predictable backup codes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Complete PortSwigger deep-dive with exact payloads for every lab variant including zero-day techniques

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Execute AS-REP Roasting to extract and crack the NTLM hashes of Active Directory user accounts that have the "Do not require Kerberos preauthentication" flag explicitly enabled. This attack generates a recoverable Ticket Granting Ticket (TGT) without requiring the attacker to authenticate first.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

ShulkwiSEC의 스킬 모두 보기

이 스킬의 문제 신고