Skip to content

Fix critical security vulnerabilities#36

Open
abhipankhar08 wants to merge 1 commit into
h9zdev:mainfrom
abhipankhar08:main
Open

Fix critical security vulnerabilities#36
abhipankhar08 wants to merge 1 commit into
h9zdev:mainfrom
abhipankhar08:main

Conversation

@abhipankhar08
Copy link
Copy Markdown

Summary

  • Remove hardcoded SECRET_KEY in both app.py and app-exe.py — replaced with SECRET_KEY env var (falls back to a runtime-generated random key with a warning)
  • Remove two /api/wigle/token endpoints that returned base64-encoded WiGLE credentials to any unauthenticated caller
  • Move all hardcoded API credentials to env varsHF_TOKEN, WIGLE_API_NAME, WIGLE_API_TOKEN, AIS_API_KEY, SHODAN_API_KEY were all hardcoded empty strings that bypassed .env loading
  • Fix path traversal in get_geojson_data — replaced naive '..' in filename check with os.path.realpath() + prefix assertion (blocks URL-encoded variants like %2F..%2F)
  • Add file upload validation on reverse-image search — MIME type allowlist (jpeg/png/gif/webp) and 10 MB size cap
  • Fix SSRF in aggressive scrape — added urlparse scheme validation before fetching arbitrary URLs from search results
  • Strip API key from logsprint(params) was printing NEWS_API_KEY in plaintext to server logs
  • Disable debug mode by defaultdebug=True was hardcoded; now gated behind FLASK_DEBUG=true env var
  • Restrict SocketIO CORS — was open to all origins; now defaults to localhost, configurable via CORS_ORIGINS env var
  • Add .gitignore and .env.example template documenting all required env vars

Test plan

  • App starts without errors: SECRET_KEY=<val> python3 app.py
  • /api/wigle/token returns 404
  • Path traversal GET /api/geojson/../../etc/passwd returns 400
  • Photo upload with Content-Type: text/plain returns 400
  • Server logs do not contain API key values
  • FLASK_DEBUG=false (default) — no interactive debugger exposed

🤖 Generated with Claude Code

- Replace hardcoded SECRET_KEY values with env-var lookup; fall back to
  a runtime-generated random key with a warning so sessions still work
- Move HF_TOKEN, WIGLE_API_NAME, WIGLE_API_TOKEN, AIS api_key, and
  SHODAN_API_KEY from hardcoded empty strings to os.environ.get()
- Remove two /api/wigle/token endpoints that returned base64-encoded
  WiGLE credentials to any unauthenticated caller
- Harden path-traversal check in get_geojson_data: replace the naive
  '..' string check with os.path.realpath() + prefix assertion
- Add MIME-type allowlist and 10 MB size cap to reverse-image upload
- Add URL scheme/netloc validation before fetching in aggressive scrape
  mode to prevent SSRF
- Strip API key from NewsAPI log line (was printed in full via params dict)
- Gate Flask debug mode behind FLASK_DEBUG env var (default off)
- Restrict SocketIO to same-origin by default via cors_allowed_origins
- Add .gitignore (excludes .env, uploads/, chroma db, __pycache__)
- Add .env.example template documenting all required env vars

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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