Skip to content

security: fix critical vulnerabilities (Cypher injection, CORS, auth, token expiry)#1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782487877-security-hardening
Open

security: fix critical vulnerabilities (Cypher injection, CORS, auth, token expiry)#1
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782487877-security-hardening

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Fixes 6 critical security issues found during a codebase audit.

Cypher injectionNeo4jGraphRepository interpolated node_type, rel_label, from_type, to_type directly into f-string Cypher queries. Added _sanitize_label(value) that validates labels against ^[A-Za-z_][A-Za-z0-9_]*$ and raises ValueError on mismatch. Applied at all 4 injection points: _build_node_query, _build_relationship_query, batch_create_edges_by_element_id, and merge_nodes.

CORS wildcards with credentialsallow_methods=["*"] and allow_headers=["*"] combined with allow_credentials=True is dangerous. Restricted to explicit lists:

allow_methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
allow_headers=["Authorization", "Content-Type", "Accept"]

Missing auth on enricher endpointsGET /api/flows/raw_materials and GET /api/flows/input_type/{input_type} had no authentication. Added current_user: Profile = Depends(get_current_user) to both.

Excessive token lifetimeACCESS_TOKEN_EXPIRE_MINUTES was 60 * 60 (2.5 days). Reduced to 60 * 24 (1 day).

No password validationProfileCreate.password accepted any string. Added Field(..., min_length=8, max_length=128).

Weak default secret.env.example shipped AUTH_SECRET=superscretchangeitplz without warning. Added comment with secrets.token_urlsafe(48) generation command.

Link to Devin session: https://app.devin.ai/sessions/16957490aade494488bbb861d2eeb3a1
Requested by: @netty-linux

- Cypher injection: add _sanitize_label() validation for Neo4j labels/types
  in repository.py (4 injection points patched)
- CORS: restrict allow_methods and allow_headers from wildcards to explicit
  lists in main.py
- Auth: add authentication to /raw_materials and /input_type/{input_type}
  endpoints in flows.py
- Token expiry: reduce from 60*60 min (2.5 days) to 60*24 min (1 day)
  in auth.py
- Password validation: add min_length=8, max_length=128 to ProfileCreate
  in profile.py
- .env.example: add warning comment about replacing default AUTH_SECRET

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@netty-linux netty-linux self-assigned this Jun 26, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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