Skip to content

fix: SERVICE_API_KEY and ADMIN_API_KEY have insecure hardcoded defaults in Settings #122

@BigBen-7

Description

@BigBen-7

Description

src/config.py sets:

SERVICE_API_KEY: str = "default_service_secret_change_me"
ADMIN_API_KEY:   str = "default_admin_secret_change_me"

These are public defaults committed to the repository. Any deployment that forgets to override them in .env silently accepts these well-known strings as valid credentials — a complete authentication bypass.

Requirements & context

  • Remove the default values for both fields — make them required (Field(...)) or validate at startup that they are not equal to the known bad defaults
  • Add a @field_validator that rejects both keys if they match the old default strings or are shorter than 32 characters
  • Update .env.example with commented-out placeholder values and a security note
  • Confirm the app raises a clear ValidationError at startup if either key is missing or is the default string

Suggested execution

git checkout -b fix/insecure-default-api-keys
  • Update src/config.py
  • Update .env.example
  • Add startup test asserting ValidationError when keys are the defaults

Guidelines

  • Never log the key values — only confirm presence and minimum length
  • PR must include: Closes #[issue_id]
  • Timeframe: 24 hours

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsecuritySecurity-related issues and fixes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions