17 lines
1.1 KiB
YAML
17 lines
1.1 KiB
YAML
# Prüfwerk's own semgrep rules for Objective-C (iOS apps), as regex patterns:
|
|
# semgrep has no Objective-C parser. Same conventions and provenance as
|
|
# cra_semgrep_swift.yaml, whose Swift rules these mirror.
|
|
# Test cases: cra_semgrep_objc.m (`semgrep --test compliance-agent/rules`).
|
|
rules:
|
|
# --- cra-ai-14: data at rest -------------------------------------------------
|
|
- id: cra-ai-14-objc-secret-in-userdefaults
|
|
languages: [regex]
|
|
severity: WARNING
|
|
message: A password, token or key is stored in NSUserDefaults, an unencrypted plist in the app container that backups and device extraction read (CWE-312). Store it in the Keychain (kSecClassGenericPassword, with a ThisDeviceOnly accessibility).
|
|
metadata:
|
|
cwe: ["CWE-312: Cleartext Storage of Sensitive Information"]
|
|
control: cra-ai-14
|
|
paths:
|
|
include: ["*.m", "*.mm"]
|
|
pattern-regex: (?i)\[\s*(?:\[\s*NSUserDefaults\s+standardUserDefaults\s*\]|\[\s*\[\s*NSUserDefaults\s+alloc\s*\]\s*initWithSuiteName:[^\]]*\]|\w*defaults)\s+set(?:Object|Value):[^\]\n]*(?:passw|passcode|token|secret|api_?key|credential|private_?key|session_?id)[^\]\n]*\]
|