Skip to content

security: isDevelopmentMode defaulting to "enabled" bypasses Firebase auth on misconfigured deploys#689

Closed
oliursahin wants to merge 1 commit intopotpie-ai:mainfrom
oliursahin:fix/dev-mode-auth-bypass-default
Closed

security: isDevelopmentMode defaulting to "enabled" bypasses Firebase auth on misconfigured deploys#689
oliursahin wants to merge 1 commit intopotpie-ai:mainfrom
oliursahin:fix/dev-mode-auth-bypass-default

Conversation

@oliursahin
Copy link
Copy Markdown

@oliursahin oliursahin commented Mar 13, 2026

Summary

os.getenv("isDevelopmentMode", "enabled") in api_key_service.py means any deployment that omits this env var silently runs in development mode — bypassing Firebase authentication and GCP Secret Manager entirely, falling back to local Fernet-only key storage with no auth enforcement.

All other call sites in the codebase already use the safe pattern:

os.getenv("isDevelopmentMode") == "enabled"   # falsy/False when unset

This PR aligns api_key_service.py with that convention.

Change

- is_dev_mode = os.getenv("isDevelopmentMode", "enabled") == "enabled"
+ is_dev_mode = os.getenv("isDevelopmentMode", "disabled") == "enabled"

One character change. No logic change for deployments that explicitly set the env var either way.

Impact

Scenario Before After
isDevelopmentMode not set dev mode ON (bypass auth) dev mode OFF (correct)
isDevelopmentMode=enabled dev mode ON dev mode ON
isDevelopmentMode=disabled dev mode OFF dev mode OFF

Test plan

  • Deploy without isDevelopmentMode set — GCP Secret Manager should be used, auth should be enforced
  • Set isDevelopmentMode=enabled explicitly — behaviour unchanged (dev mode active)
  • Set isDevelopmentMode=disabled explicitly — behaviour unchanged (dev mode inactive)

Summary by CodeRabbit

  • Security
    • Development mode now defaults to disabled, requiring explicit enablement. This improves default security posture for API key management by adopting a more secure default configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 13, 2026

Walkthrough

The development-mode detection logic in the API key service changes from defaulting to enabled to defaulting to disabled. Development mode now requires explicit opt-in via the isDevelopmentMode environment variable being set to "enabled" rather than defaulting to true when unset.

Changes

Cohort / File(s) Summary
Development Mode Configuration
app/modules/auth/api_key_service.py
Modified development-mode detection default from "enabled" to "disabled", making development mode opt-in rather than opt-out. The behavior for Secret Manager gating remains unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • nndn

Poem

🐰 A toggle flips with gentle care,
Development mode now must declare!
"Enabled" spoken, secrets flow,
Otherwise they stay below. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title describes a security issue about isDevelopmentMode defaulting behavior, but the actual change is inverting the default from 'enabled' to 'disabled' to fix a bypass—the title correctly highlights the security problem being resolved.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@oliursahin oliursahin force-pushed the fix/dev-mode-auth-bypass-default branch from af463ea to cd8e217 Compare March 13, 2026 12:43
`os.getenv("isDevelopmentMode", "enabled")` caused any deployment that
omitted this env var to silently run in development mode — bypassing
GCP Secret Manager and falling back to local Fernet-only key storage.

All other call sites in the codebase already use the safe pattern
`os.getenv("isDevelopmentMode") == "enabled"` (falsy when unset).
This aligns api_key_service.py with that convention by changing the
default to "disabled".

Co-authored-by: zerotrail-ai <zerotrail-ai@users.noreply.github.com>
@oliursahin oliursahin force-pushed the fix/dev-mode-auth-bypass-default branch from cd8e217 to b2ad2de Compare March 13, 2026 12:43
@sonarqubecloud
Copy link
Copy Markdown

@oliursahin oliursahin changed the title fix(auth): change isDevelopmentMode default from "enabled" to "disabled" security: isDevelopmentMode defaulting to "enabled" bypasses Firebase auth on misconfigured deploys Mar 13, 2026
@oliursahin oliursahin closed this by deleting the head repository Mar 30, 2026
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.

1 participant