Skip to content

fix: exempt framework binaries from all heuristic secret scans - #8747

Closed
beastoin wants to merge 2 commits into
mainfrom
fix/scanner-framework-v2
Closed

beastoin wants to merge 2 commits into
mainfrom
fix/scanner-framework-v2

Conversation

@beastoin

@beastoin beastoin commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #8741 — the v1 fix only skipped the regex token scan for .framework/ dirs. v2 extended this to all three heuristic checks for frameworks, but the real problem is broader: compiled binaries outside .framework/ also false-positive.

False positive sources in real Codemagic builds:

  • Runner (Mach-O binary, no extension) — BoringSSL constants like CLIENT_EARLY_TRAFFIC_SECRET
  • BatteryWidget.appex/BatteryWidget — enum names like CREDENTIAL_MISMATCH, API_KEY
  • GoogleService-Info.plist — config key names like API_KEY, GCM_SENDER_ID
  • .framework/ contents — TwilioVoice, Flutter, Firebase SDK constants

Root cause

The regex scanner \b[A-Z][A-Z0-9_]{2,}\b matches ANY uppercase identifier with 3+ chars. In compiled iOS binaries, thousands of such identifiers exist as enum names, config keys, and SDK constants — none are actual secrets.

Fix

Replace the in_framework check with _is_text_scannable() — heuristic scans (private key markers, denied name bytes, regex tokens) ONLY run on files with known text extensions (.env, .json, .yaml, .swift, .dart, etc.).

Still checked on ALL files (including binaries):

  • Forbidden filenames/suffixes (.env bundled, keystore files, etc.)
  • Actual CI secret values leaked into any file

Also fixed

  • Empty glob (Android nullglob case): exit 0 with WARNING instead of exit 1

Tests

14 tests pass covering:

  • Framework binary tokens (skipped)
  • Compiled app binaries — Runner, appex (skipped)
  • GoogleService-Info.plist config keys (skipped)
  • Private key in text file (caught)
  • Denied name in text file (caught)
  • CI secret values in framework binary (caught)
  • Empty glob and no-args (pass with warning)

Closes #8742

by AI for @beastoin

…0 on empty glob

v1 fix only skipped the regex token scan for .framework dirs but left
private key markers and exact denied name byte searches running on
framework binaries — those also false-positive on compiled SDK constants.

Now framework files only get checked for:
- Forbidden filenames/suffixes
- Actual CI secret values leaked into the binary

Empty glob now exits 0 with WARNING instead of 1 — the build step
already fails if no artifact was produced.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 2 files

Confidence score: 2/5

  • In scripts/scan-public-artifact-secrets.py, returning success (0) when no artifact is passed creates a fail-open path in the release secret scan, so misconfigured or empty invocations could let leaked secrets pass into published artifacts undetected. Treat empty input as an error by default and add an explicit allow-empty flag only for the Android nullglob case before merging.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/scan-public-artifact-secrets.py">

<violation number="1" location="scripts/scan-public-artifact-secrets.py:275">
P1: Returning 0 when no artifact is provided makes the release secret scanner fail open. Add an explicit allow-empty mode for the Android nullglob case instead of treating all empty invocations as successful.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

print("No artifacts to scan (glob matched nothing).", file=sys.stderr)
return 1
print("WARNING: No artifacts to scan (glob matched nothing). Skipping.", file=sys.stderr)
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Returning 0 when no artifact is provided makes the release secret scanner fail open. Add an explicit allow-empty mode for the Android nullglob case instead of treating all empty invocations as successful.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/scan-public-artifact-secrets.py, line 275:

<comment>Returning 0 when no artifact is provided makes the release secret scanner fail open. Add an explicit allow-empty mode for the Android nullglob case instead of treating all empty invocations as successful.</comment>

<file context>
@@ -270,8 +271,8 @@ def main() -> int:
-        print("No artifacts to scan (glob matched nothing).", file=sys.stderr)
-        return 1
+        print("WARNING: No artifacts to scan (glob matched nothing). Skipping.", file=sys.stderr)
+        return 0
 
     policy = load_policy()
</file context>

The framework-only exemption was insufficient — compiled binaries outside
.framework/ (Runner, BatteryWidget.appex) and config files (.plist) also
produce false positives from the regex token scanner.

Now heuristic scans (private key markers, denied name bytes, regex tokens)
only run on files with known text extensions (.env, .json, .yaml, .swift,
.dart, etc.).  All files still get checked for forbidden filenames/suffixes
and actual CI secret value leaks.

Tests: 14 pass covering framework binaries, compiled app binaries, plist
config keys, text file catches, CI value leaks, and empty glob handling.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/scan-public-artifact-secrets.py">

<violation number="1" location="scripts/scan-public-artifact-secrets.py:89">
P2: Hidden `.env` files are no longer treated as text-scannable because `Path.suffix` is empty for `.env`. This can miss private-key markers or denied-name byte/token leaks in bundled `.env` artifacts.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

"""
if any(part.endswith(FRAMEWORK_DIR_SUFFIXES) for part in rel.parts):
return False
return file_path.suffix.lower() in HEURISTIC_SCAN_EXTENSIONS

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Hidden .env files are no longer treated as text-scannable because Path.suffix is empty for .env. This can miss private-key markers or denied-name byte/token leaks in bundled .env artifacts.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/scan-public-artifact-secrets.py, line 89:

<comment>Hidden `.env` files are no longer treated as text-scannable because `Path.suffix` is empty for `.env`. This can miss private-key markers or denied-name byte/token leaks in bundled `.env` artifacts.</comment>

<file context>
@@ -37,6 +37,56 @@
+    """
+    if any(part.endswith(FRAMEWORK_DIR_SUFFIXES) for part in rel.parts):
+        return False
+    return file_path.suffix.lower() in HEURISTIC_SCAN_EXTENSIONS
 
 
</file context>
Suggested change
return file_path.suffix.lower() in HEURISTIC_SCAN_EXTENSIONS
return file_path.name == ".env" or file_path.name.endswith(".env") or file_path.suffix.lower() in HEURISTIC_SCAN_EXTENSIONS

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

security-sensitive backend/scripts fix (exempt framework binaries from secret scans) — approve only, when-in-doubt downgrade

@Git-on-my-level Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior labels Jul 1, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the follow-up here — the direction makes sense for reducing noisy false positives from compiled iOS artifacts, and the included test script passes locally.

I’m requesting changes because this touches the release secret scanner and I found two fail-open edge cases that should be tightened before merge:

  1. .env is listed in HEURISTIC_SCAN_EXTENSIONS, but Path('.env').suffix is empty. A bundled file literally named .env still runs the .env variable-name parser, but it no longer gets the private-key marker / denied-name byte / token heuristic scan. I reproduced an IPA containing Payload/Runner.app/.env with private-key material and the scanner exited 0 (Public artifact secret scan passed.). Please treat .env as text-scannable explicitly, not only via suffix.

  2. Returning 0 for every no-argument invocation makes the scanner fail open if an artifact glob or variable is accidentally empty in a release path. I understand the Android nullglob motivation, but this should be an explicit allow-empty mode or otherwise scoped to that workflow case rather than changing the scanner’s default no-artifact behavior.

Verification I ran with a stripped environment:

  • env -i ... bash scripts/test-scan-public-artifact-secrets.sh -> 14 passed, 0 failed
  • targeted .env private-key artifact -> scanner exited 0 unexpectedly
  • no-args scanner invocation -> scanner exited 0

Because this is security/workflow-sensitive release tooling, please add regressions for those cases before this lands. I’m not treating this as malicious; it looks like a real false-positive fix that just needs the fail-open edges closed.

@beastoin

beastoin commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Closing — manager decided to hand scanner fix ownership back to @Git-on-my-level who authored the original scanner. See #8742 for full details on the false positive sources discovered during Codemagic builds.

by AI for @beastoin

@beastoin beastoin closed this Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Hey @beastoin 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our roadmap and vision

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community! 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-review Touches auth, provider routing, secrets, or security-sensitive surfaces workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secret scanner false positives block mobile release (Codemagic)

3 participants