Skip to content

fix: skip secret scanner regex on framework binaries - #8741

Merged
beastoin merged 3 commits into
mainfrom
fix/scanner-framework-false-positives
Jul 1, 2026
Merged

beastoin merged 3 commits into
mainfrom
fix/scanner-framework-false-positives

Conversation

@beastoin

@beastoin beastoin commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes Codemagic iOS and Android build failures caused by the secret scanner script (scripts/scan-public-artifact-secrets.py).

iOS: framework binary false positives

The scanner regex \b[A-Z][A-Z0-9_]{2,}\b scans all files including compiled third-party framework binaries. BoringSSL constants in TwilioVoice.framework and Flutter.framework (e.g. CLIENT_EARLY_TRAFFIC_SECRET, PRIVATE_KEY_ENCODE_ERROR) match denied patterns (^|_)SECRET($|_) and (^|_)PRIVATE_KEY($|_).

Fix: Skip the regex variable-like token scan for files inside .framework/ and .xcframework/ directories. All other checks still apply (forbidden files, private key markers, env scanning, exact denied names, CI value leak detection).

Android: argument error on empty glob

shopt -s nullglob in codemagic.yaml causes the AAB glob to expand to nothing when no AAB exists. argparse crashes with "the following arguments are required: artifacts" instead of surfacing the actual build failure.

Fix: Change nargs='+' to nargs='*' with explicit empty-check for a clearer error message.

Testing

  • Python compilation check: PASS
  • Black formatting: PASS
  • Logic unit tests: framework path detection verified for TwilioVoice.framework, Flutter.xcframework, and non-framework paths
  • CODEx review: approved, no blocking issues. Other security checks (forbidden files, private key markers, exact denied names, CI values) still apply inside frameworks.

Risks

Closes #8742

by AI for @beastoin

iOS builds fail because BoringSSL constants in TwilioVoice.framework and
Flutter.framework (e.g. CLIENT_EARLY_TRAFFIC_SECRET, PRIVATE_KEY_ENCODE_ERROR)
match the denied name patterns. These are compiled third-party constants, not
actual secrets.

Android auto-deploy fails because nullglob expands to nothing when the AAB
hasn't been produced yet, causing argparse to error on zero arguments.

Changes:
- Skip regex variable-like token scan for files inside .framework/.xcframework dirs
- Change nargs='+' to nargs='*' with explicit empty-check for clearer error

@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.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

beastoin added 2 commits July 1, 2026 10:53
Covers iOS and Android invocation patterns from codemagic.yaml:
- Framework BoringSSL constants pass (TwilioVoice, Flutter, xcframework)
- Android nullglob + empty glob handled gracefully
- Real secrets outside frameworks still caught
- Private key markers inside frameworks still caught
- Exact denied names inside frameworks still caught

@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 1 file (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/test-scan-public-artifact-secrets.sh">

<violation number="1" location="scripts/test-scan-public-artifact-secrets.sh:104">
P2: `shopt -s globstar` requires bash 4.0+ — the script will fail on macOS default bash 3.2 without a notice</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

echo ""
echo "=== Codemagic Android workflow (lines 430-431: shopt -s globstar nullglob + glob) ==="
run_expect_pass "android-aab-with-nullglob" \
bash -c "cd '$WORK/android' && shopt -s globstar nullglob && python3 '$SCANNER' build/**/outputs/**/*.aab"

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: shopt -s globstar requires bash 4.0+ — the script will fail on macOS default bash 3.2 without a notice

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

<comment>`shopt -s globstar` requires bash 4.0+ — the script will fail on macOS default bash 3.2 without a notice</comment>

<file context>
@@ -0,0 +1,139 @@
+echo ""
+echo "=== Codemagic Android workflow (lines 430-431: shopt -s globstar nullglob + glob) ==="
+run_expect_pass "android-aab-with-nullglob" \
+  bash -c "cd '$WORK/android' && shopt -s globstar nullglob && python3 '$SCANNER' build/**/outputs/**/*.aab"
+
+echo ""
</file context>

@beastoin

beastoin commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

lgtm

@beastoin
beastoin merged commit d740a74 into main Jul 1, 2026
3 checks passed
@beastoin
beastoin deleted the fix/scanner-framework-false-positives branch July 1, 2026 12:13
pull Bot pushed a commit to AmirulAndalib/omi that referenced this pull request Jul 1, 2026
Re-bump build number from 969 to 970. Build 969 tag failed to re-trigger
Codemagic after the scanner fix (BasedHardware#8741) — re-tagging the same name
doesn't generate a new webhook, and the tag-triggered workflows parse
`CM_TAG` for the build number so it must be purely numeric.

This creates a clean new tag target at the new main HEAD (includes
scanner fix).

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/8745?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
mdmohsin7 added a commit that referenced this pull request Jul 1, 2026
## Why

The latest TestFlight builds (**1.0.542+969 / +970**) shipped broken.
Root causes, both from the public-client secret-boundary hardening
(#8716, #8717, #8733, #8741):

1. **Null API base URL → crash on launch.** Those PRs renamed every app
env var to a `PUBLIC_` prefix and moved Envied's source from `.env` →
`.client.env`. The Codemagic dashboard still defines the **old** names,
so the `PUBLIC_*` exports resolved empty, `create-public-client-env.sh`
skipped them, and Envied baked `null` into prod. `Env.apiBaseUrl!` then
force-unwrapped to a crash.
2. **`flutter build ipa` failure.** The post-build artifact scanner
flagged Firebase/SDK constant strings (`ERROR_INVALID_CREDENTIAL`,
`PROJECT_TOKEN`, …) inside the compiled `BatteryWidget.appex` Mach-O
binary as "server-only tokens" — false positives.

## What this does

- **Restores `codemagic.yaml` + `app/lib/env/**` to the last-good
(1.0.533) state** — byte-identical, verified 0-diff. The prod build
again reads the old var names that are still in the Codemagic dashboard.
- **Reverts the coupled secret-scanner apparatus as one unit** (it's
cross-wired through `lint.yml`, the git hooks, and the backend registry,
so half-reverting would fail CI): scanner scripts,
`client_env_policy.yaml`, the boundary test, the backend secret-consumer
registry, and the `lint.yml`/`pre-commit`/`pre-push` enforcement.
- Also restores `openai.dart`, the STT provider/polling code, app setup
scripts, and env tests to baseline.

## What is deliberately preserved (independent web hardening)

Not reverted — these removed baked secrets from the **web** images and
are unrelated to the mobile break:
- `.github/workflows/gcp_apps_js.yml`, `gcp_frontend.yml`,
`gcp_personas.yml` (baked-secret removal from Docker build args +
env-choice/SHA tagging)
- `web/frontend/**`, `web/personas-open-source/**`, `plugins/apps-js/**`

## Verification

- `codemagic.yaml` + `app/lib/env` diff vs the pre-hardening baseline:
**0 lines**; no `PUBLIC_API_BASE_URL` left in `codemagic.yaml`.
- No dangling references to any deleted script anywhere in the tree.
- `dart analyze` on the reverted app code: no errors.
- `flutter test` (env + capture_provider): **75/75 pass**.

## Note

This returns the mobile client to its long-standing pre-1.0.542 secret
posture (OpenAI/Google client secrets baked into the binary again). That
is the status quo that shipped in 1.0.533 and every prior release — not
a new exposure — but the underlying hardening should be re-attempted
later by adding the `PUBLIC_*` vars to Codemagic first, then re-landing,
rather than renaming under a live dashboard.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/8772?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
pull Bot pushed a commit to Mu-L/omi that referenced this pull request Jul 1, 2026
Builds 1.0.542+969/970 shipped broken: the secret-boundary PRs (BasedHardware#8716, BasedHardware#8717,
BasedHardware#8733, BasedHardware#8741) renamed every app env var to a PUBLIC_ prefix and moved Envied's
source to .client.env, but the Codemagic dashboard still defines the old names.
The PUBLIC_* exports resolved empty, create-public-client-env.sh skipped them,
and Envied baked null into prod — so Env.apiBaseUrl! force-unwrapped to a crash
on launch. The post-build artifact scanner also false-positived on Firebase/SDK
constant strings (ERROR_INVALID_CREDENTIAL, PROJECT_TOKEN) inside the compiled
BatteryWidget.appex, failing 'flutter build ipa'.

Restores codemagic.yaml and app/lib/env to the last-good (1.0.533) state so the
prod build works with the existing dashboard vars, and reverts the coupled
secret-scanner apparatus (scanner scripts, client_env_policy, boundary test,
backend secret-consumer registry, and the lint.yml/pre-commit/pre-push
enforcement) as one unit.

Preserves the independent web hardening: the gcp_apps_js/frontend/personas
workflows keep their baked-secret removal + env-choice/SHA-tagging, and
web/frontend, web/personas-open-source, and plugins/apps-js are untouched.
mdmohsin7 added a commit that referenced this pull request Jul 3, 2026
…8908)

## Summary

Removes the six `scan-public-artifact-secrets.py` invocations (and the
`AAB_ARTIFACTS` find lines that existed only to feed them) from the
iOS/Android prod and shorebird-patch workflows in `codemagic.yaml`. The
scanner script, its tests, `client_env_policy.yaml`, and the desktop
release guard are untouched.

## Why

Every prod mobile build is currently failing on false positives. The
variable-like-token heuristic greps ALL-CAPS tokens out of compiled
artifacts and matches them against `denied_name_patterns` — and the
flagged tokens are all Firebase Auth SDK error constants baked into the
statically linked `Runner` executable, plus `P12` in the dSYM
`Symbols/*.symbols` files:

- `ERROR_INVALID_CREDENTIAL`, `MISSING_APP_CREDENTIAL`,
`INVALID_LOGIN_CREDENTIALS`, `MISSING_MFA_PENDING_CREDENTIAL`,
`INVALID_MFA_PENDING_CREDENTIAL` → `(^|_)CREDENTIALS?($|_)`
- `ERROR_CUSTOM_TOKEN_MISMATCH`, `ERROR_INVALID_CUSTOM_TOKEN`,
`MISSING_IOS_APP_TOKEN` → `(^|_)TOKEN($|_)`
- `INVALID_PASSWORD` → `(^|_)PASSWORD($|_)`, `API_KEY` →
`(^|_)API_KEY($|_)`, `P12` → `(^|_)P12($|_)`

The `.framework`/`.xcframework` carve-out from #8741 never covered the
main binary or the top-level `Symbols/` directory.

This is the second time this scan has broken the mobile release on SDK
constant strings (first: `BatteryWidget.appex`, reverted in
7123930; re-landed hours later by #8773). The mobile build steps
inject no server env values into the bundle, so scanning compiled Mach-O
output for env-var-shaped names is noise by construction — the scanner's
real protection (the check for actual CI secret *values*) never fired.

cc @Git-on-my-level — if this scan is re-landed a third time, it needs
to exclude compiled executables and symbol files from the name-pattern
heuristic first (the exact-name and secret-value checks can safely keep
running on binaries).

## Validation

- `python3 .github/scripts/check-release-process-guards.py` passes (the
guard requires `scripts/scan-public-artifact-secrets.py` to exist; it
still does)
- `codemagic.yaml` parses as valid YAML; zero remaining scanner
references; no dangling `AAB_ARTIFACTS` uses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/8908?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
pull Bot pushed a commit to codingwatching/omi that referenced this pull request Jul 3, 2026
The variable-like-token heuristic in scan-public-artifact-secrets.py
false-positives on every mobile build: Firebase Auth SDK error constants
(ERROR_INVALID_CREDENTIAL, INVALID_LOGIN_CREDENTIALS, MISSING_IOS_APP_TOKEN,
INVALID_PASSWORD, API_KEY) compiled into the statically linked Runner
executable and P12 in the dSYM Symbols/*.symbols files all match the
denied_name_patterns in client_env_policy.yaml. The .framework/.xcframework
carve-out from BasedHardware#8741 never covered the main binary or top-level Symbols/.

This is the second time the scanner has broken the Codemagic mobile
release on SDK constant strings (see revert 7123930); PR BasedHardware#8773
re-landed the wiring hours after that revert. The mobile build injects
no server env values, so scanning compiled Mach-O output for ALL-CAPS
env-var-shaped names yields only noise.

Removes the six scan invocations (and the AAB_ARTIFACTS find lines that
existed only to feed them) from the iOS/Android prod and shorebird-patch
workflows. The scanner script, its tests, and the desktop release guard
(which only requires the file to exist) are untouched.
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.

Secret scanner false positives block mobile release (Codemagic)

1 participant