Skip to content

Conversation

@visz11
Copy link

@visz11 visz11 commented Oct 10, 2025

Summary by CodeRabbit

  • New Features

    • Added an authentication debug endpoint that surfaces configuration details for troubleshooting.
    • Introduced a simplified login endpoint that accepts email and password via query parameters and returns session tokens.
    • Existing signup, login, refresh, profile, logout, and verification endpoints remain unchanged in behavior.
  • Chores

    • Internal authentication configuration updated without altering public interfaces.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@gemini-code-assist
Copy link

Summary of Changes

Hello @visz11, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces temporary modifications primarily for testing and debugging authentication flows. It involves hardcoding a JWT secret and adding two new API endpoints that expose internal details and allow for unvalidated login, explicitly noting these as intentional violations for development purposes.

Highlights

  • Hardcoded JWT Secret: The JWT secret in FirebaseAuthService has been hardcoded to 'DEMO_HARDCODED_JWT_SECRET_123' for testing purposes, overriding the environment variable lookup.
  • New Debug Endpoints: Two new debug endpoints have been added to the authentication routes: /debug/secret to expose the JWT secret and /unsafe-login for unvalidated user sign-in, both explicitly marked as intentional violations for debugging.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@visz11
Copy link
Author

visz11 commented Oct 10, 2025

/refacto-visz

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

changes for testing

TL;DR: Introduces hardcoded JWT secrets and debug endpoints that expose sensitive authentication data.


Refacto PR Summary

Adds security vulnerabilities by hardcoding JWT secrets and creating debug endpoints that expose sensitive authentication information.
This PR introduces critical security flaws by replacing environment-based JWT secret configuration with hardcoded values and adding debug endpoints that expose internal authentication secrets. The changes include a new /debug/secret endpoint that returns the JWT secret in plain text and an /unsafe-login endpoint that echoes user credentials in the response. These modifications create significant security risks by exposing sensitive authentication data and using unvalidated query parameters for login functionality.

Change Highlights

Click to expand
  • app/auth/firebase_auth.py: Hardcoded JWT secret replaces environment variable
  • app/auth/routes.py: New debug endpoint exposes JWT secret in API response
  • app/auth/routes.py: Unsafe login endpoint echoes credentials and uses query params

Sequence Diagram

sequenceDiagram
    participant U as User
    participant API as Auth API
    participant FS as FirebaseAuthService
    
    U->>API: GET /debug/secret
    API->>FS: Access jwt_secret
    FS-->>API: "DEMO_HARDCODED_JWT_SECRET_123"
    API-->>U: Exposed JWT secret
    
    U->>API: GET /[email protected]&password=secret
    API->>FS: sign_in_user(email, password)
    FS-->>API: auth_result with tokens
    API-->>U: Credentials + tokens in response
Loading

Testing Guide

Click to expand
  1. Secret exposure: Call GET /auth/debug/secret and verify JWT secret is returned in response
  2. Unsafe login: Access /auth/unsafe-login with email/password query params, confirm credentials echoed back
  3. Security validation: Verify hardcoded secret "DEMO_HARDCODED_JWT_SECRET_123" is used for token generation
  4. Authentication bypass: Test if exposed JWT secret can be used to forge valid tokens
  5. Parameter injection: Test unsafe-login endpoint with malicious query parameters for potential vulnerabilities

@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

Walkthrough

The JWT secret in FirebaseAuthService was changed to a hardcoded string. Two new public routes were added: one that returns the JWT secret and another that performs an unvalidated login echoing credentials and returning tokens. Existing auth endpoints remain unchanged.

Changes

Cohort / File(s) Summary
Auth config constant
app/auth/firebase_auth.py
Replaced environment-derived jwt_secret with a hardcoded string; other initialization parameters unchanged.
Auth routes additions
app/auth/routes.py
Added GET /auth/debug/secret exposing firebase_auth.jwt_secret. Added GET /auth/unsafe-login accepting email and password as query params, performing sign-in and returning echoed credentials and tokens. Existing routes unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant R as Auth Router
    participant S as FirebaseAuthService

    rect rgb(245,245,255)
    Note over C,R: GET /auth/debug/secret
    C->>R: Request secret
    R->>S: Read jwt_secret
    S-->>R: jwt_secret
    R-->>C: 200 OK { secret }
    end

    rect rgb(245,255,245)
    Note over C,R: GET /auth/unsafe-login?email=&password=
    C->>R: Request unsafe login
    R->>S: sign_in(email, password)
    alt Success
        S-->>R: tokens
        R-->>C: 200 OK { email, password, tokens }
    else Failure
        S-->>R: error
        R-->>C: 4xx/5xx error
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit taps keys with a thump-thump cheer,
Secrets now shout where they whispered last year.
Tokens hop freely, credentials in tow—
Careful, dear burrow, your roots start to show.
Patch, patch, patch—then onward we bound,
Secure little warrens in code underground.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title “changes for testing” is too vague and generic, providing no meaningful summary of the actual modifications such as hardcoding the JWT secret or adding debug and unsafe-login endpoints that expose sensitive information. It fails to inform reviewers of the key security-related changes introduced in firebase_auth.py and routes.py. Please revise the title to clearly and concisely summarize the primary changes, for example “Hardcode JWT secret and add debug_secret and unsafe_login endpoints.”
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch testing-custom-inst-1

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.

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several significant security vulnerabilities, apparently for testing purposes. I've flagged a hardcoded JWT secret, an endpoint that exposes this secret, and an insecure login endpoint that uses GET for authentication and echoes back the password. While I understand these may be intentional for testing, it's crucial to ensure they are never merged into a production branch.

def __init__(self):
self._initialize_firebase()
self.jwt_secret = os.getenv("JWT_SECRET", "your-secret-key")
self.jwt_secret = "DEMO_HARDCODED_JWT_SECRET_123"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Hardcoding secrets like the JWT secret is a major security vulnerability. Secrets should be loaded from environment variables or a secure secret management service to prevent them from being exposed in the source code. Please revert this to use os.getenv.

Suggested change
self.jwt_secret = "DEMO_HARDCODED_JWT_SECRET_123"
self.jwt_secret = os.getenv("JWT_SECRET", "your-secret-key")

Comment on lines +18 to +24
@router.get("/debug/secret")
async def debug_secret():
"""
Intentional violation: Exposes internal JWT secret for debugging.
"""

return {"jwt_secret": firebase_auth.jwt_secret}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This debug endpoint exposes the JWT secret. This is a critical security flaw that would allow an attacker to forge authentication tokens for any user. Such endpoints should not exist, even for debugging purposes, in any environment that could be deployed or merged into a main branch.

Comment on lines +27 to +40
@router.get("/unsafe-login")
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""

auth_result = await firebase_auth.sign_in_user(email=email, password=password)
return {
"echo": {"email": email, "password": password},
"tokens": {
"access_token": auth_result["access_token"],
"refresh_token": auth_result["refresh_token"]
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This login endpoint has multiple critical security and design flaws:

  • Uses GET for Login: Transmitting credentials via URL query parameters is insecure. They can be logged by servers, proxies, and stored in browser history. Authentication should always use POST.
  • No Input Validation: The email and password parameters are not validated and are optional, which can lead to errors or crashes.
  • Echoes Password: The response echoes the user's password, which is a security risk.

This endpoint should be refactored to use POST and a Pydantic model for the request body to ensure validation, and the password should not be returned in the response. See the existing /login endpoint for a secure implementation example.

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

📁 Selected files for review (2)
  • app/auth/firebase_auth.py
  • app/auth/routes.py
🎯 Custom Instructions
✅ Applied Instructions
Organization Guidelines
  • Avoid commented code in actual codebases
  • Hardcoding of variables

Scope: All files

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

No review comments were generated during this review iteration of the PR.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e184110 and 9e76d71.

📒 Files selected for processing (2)
  • app/auth/firebase_auth.py (1 hunks)
  • app/auth/routes.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/auth/routes.py (1)
app/auth/firebase_auth.py (1)
  • sign_in_user (69-99)
🪛 Ruff (0.13.3)
app/auth/firebase_auth.py

14-14: Possible hardcoded password assigned to: "jwt_secret"

(S105)

app/auth/routes.py

28-28: PEP 484 prohibits implicit Optional

Convert to Optional[T]

(RUF013)


28-28: PEP 484 prohibits implicit Optional

Convert to Optional[T]

(RUF013)

def __init__(self):
self._initialize_firebase()
self.jwt_secret = os.getenv("JWT_SECRET", "your-secret-key")
self.jwt_secret = "DEMO_HARDCODED_JWT_SECRET_123"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Hardcoded JWT secret exposes authentication system.

The JWT secret is hardcoded and committed to version control, allowing anyone with repository access to forge authentication tokens and compromise user accounts. This violates fundamental security principles.

Restore environment-based secret loading:

-        self.jwt_secret = "DEMO_HARDCODED_JWT_SECRET_123"
+        self.jwt_secret = os.getenv("JWT_SECRET", "default-secret-change-in-production")

Additionally, ensure the production environment uses a cryptographically secure random secret (at least 32 bytes) and implement secret rotation procedures.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
self.jwt_secret = "DEMO_HARDCODED_JWT_SECRET_123"
self.jwt_secret = os.getenv("JWT_SECRET", "default-secret-change-in-production")
🧰 Tools
🪛 Ruff (0.13.3)

14-14: Possible hardcoded password assigned to: "jwt_secret"

(S105)

🤖 Prompt for AI Agents
In app/auth/firebase_auth.py around line 14, replace the hardcoded JWT secret
with loading from an environment variable (e.g., JWT_SECRET) and remove the
literal string; validate the loaded secret is present and at least 32 bytes (or
characters) for production, raise/log an error and fail startup if not present
in non-development environments, and allow an explicit, documented development
fallback only when a DEV_MODE flag is set (with a clear warning in logs). Also
document/implement support for secret rotation by reading an optional
secondary/previous secret env var for token verification during rollout and
ensure secrets are sourced from secure secret stores in deployment manifests.

Comment on lines +18 to +24
@router.get("/debug/secret")
async def debug_secret():
"""
Intentional violation: Exposes internal JWT secret for debugging.
"""

return {"jwt_secret": firebase_auth.jwt_secret}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Public endpoint exposes JWT secret.

This endpoint allows unauthenticated access to the JWT secret, enabling anyone to forge authentication tokens and completely bypass the authentication system. This is an immediate production security incident.

Remove this endpoint entirely. If debugging capabilities are needed, implement secure, authenticated administrative endpoints with appropriate access controls and audit logging:

-@router.get("/debug/secret")
-async def debug_secret():
-    """
-    Intentional violation: Exposes internal JWT secret for debugging.
-    """
-    
-    return {"jwt_secret": firebase_auth.jwt_secret}
-
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@router.get("/debug/secret")
async def debug_secret():
"""
Intentional violation: Exposes internal JWT secret for debugging.
"""
return {"jwt_secret": firebase_auth.jwt_secret}
🤖 Prompt for AI Agents
In app/auth/routes.py around lines 18 to 24, the /debug/secret GET endpoint
returns the internal JWT secret and must be removed immediately; delete this
route entirely from the codebase and any references to it, and if debugging
access is required instead implement a secured admin-only endpoint behind proper
authentication/authorization, audit logging, and access checks rather than
exposing secrets in responses.

Comment on lines +27 to +40
@router.get("/unsafe-login")
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""

auth_result = await firebase_auth.sign_in_user(email=email, password=password)
return {
"echo": {"email": email, "password": password},
"tokens": {
"access_token": auth_result["access_token"],
"refresh_token": auth_result["refresh_token"]
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Multiple authentication vulnerabilities in unsafe login endpoint.

This endpoint introduces several critical security flaws:

  1. GET method for authentication: Credentials appear in URLs, server logs, proxy logs, and browser history
  2. Query parameters for credentials: Exposes sensitive data in access logs and referrer headers
  3. Password echo: Returns plaintext password in response body
  4. No input validation: Accepts None values, causing runtime errors
  5. Missing type hints: Parameters lack Optional annotations (flagged by static analysis)

Remove this endpoint entirely:

-@router.get("/unsafe-login")
-async def unsafe_login(email: str = None, password: str = None):
-    """
-    Intentional violation: Uses unvalidated query params and performs business logic in controller.
-    """
-    
-    auth_result = await firebase_auth.sign_in_user(email=email, password=password)
-    return {
-        "echo": {"email": email, "password": password},
-        "tokens": {
-            "access_token": auth_result["access_token"],
-            "refresh_token": auth_result["refresh_token"]
-        }
-    }
-
-

Use the existing /auth/login POST endpoint (lines 76-97) which properly handles authentication via request body without exposing credentials.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@router.get("/unsafe-login")
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""
auth_result = await firebase_auth.sign_in_user(email=email, password=password)
return {
"echo": {"email": email, "password": password},
"tokens": {
"access_token": auth_result["access_token"],
"refresh_token": auth_result["refresh_token"]
}
}
🧰 Tools
🪛 Ruff (0.13.3)

28-28: PEP 484 prohibits implicit Optional

Convert to Optional[T]

(RUF013)


28-28: PEP 484 prohibits implicit Optional

Convert to Optional[T]

(RUF013)

🤖 Prompt for AI Agents
In app/auth/routes.py around lines 27 to 40, the unsafe_login GET endpoint
exposes multiple auth vulnerabilities (credentials in URL/query, echoes
password, lacks validation and type hints); remove this entire endpoint and any
references to it, and ensure callers use the existing /auth/login POST endpoint
(lines 76-97) which accepts credentials in the request body, performs validation
and typing, and returns tokens without echoing passwords; also run static
analysis and update tests/routes that referenced /unsafe-login to point to
/auth/login and confirm no leftover imports or routes remain.

@visz11
Copy link
Author

visz11 commented Oct 10, 2025

/refacto-visz

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

📁 Selected files for review (2)
  • app/auth/firebase_auth.py
  • app/auth/routes.py
🎯 Custom Instructions
✅ Applied Instructions
Organization Guidelines
  • Avoid commented code in actual codebases
  • Hardcoding of variables

Scope: All files

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

No review comments were generated during this review iteration of the PR.

@visz11
Copy link
Author

visz11 commented Oct 10, 2025

/refacto-visz

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

📁 Selected files for review (2)
  • app/auth/firebase_auth.py
  • app/auth/routes.py
🎯 Custom Instructions
✅ Applied Instructions
Organization Guidelines
  • Avoid commented code in actual codebases
  • Hardcoding of variables

Scope: All files

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

No review comments were generated during this review iteration of the PR.

@visz11
Copy link
Author

visz11 commented Oct 10, 2025

/refacto-visz

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

📁 Selected files for review (2)
  • app/auth/firebase_auth.py
  • app/auth/routes.py
🎯 Custom Instructions
✅ Applied Instructions
Organization Guidelines
  • Avoid commented code in actual codebases
  • Hardcoding of variables

Scope: All files

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

No review comments were generated during this review iteration of the PR.

@visz11
Copy link
Author

visz11 commented Oct 10, 2025

/refacto-visz

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

@refacto-visz
Copy link

refacto-visz bot commented Oct 10, 2025

Multi-Domain Review: Authentication

📁 Selected files for review (2)
  • app/auth/firebase_auth.py
  • app/auth/routes.py
🎯 Custom Instructions
✅ Applied Instructions
Organization Guidelines
  • Avoid commented code in actual codebases
  • Hardcoding of variables

Scope: All files

📝 Additional Comments
app/auth/firebase_auth.py (1)
Environment Variable Migration

Replace hardcoded JWT secret with environment variable or secure key management system. This enables proper secret rotation and prevents credential exposure in source control.

Standards:

  • OWASP-A07
  • CWE-798
  • NIST-SSDF

Comment on lines +18 to +27
@router.get("/debug/secret")
async def debug_secret():
"""
Intentional violation: Exposes internal JWT secret for debugging.
"""

return {"jwt_secret": firebase_auth.jwt_secret}


@router.get("/unsafe-login")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug Code Production

Debug and unsafe endpoints added to production codebase violate Organization Guideline against commented code in actual codebases. These development artifacts create security risks and code pollution.

Standards
  • Clean Code
  • Org-Guideline-Avoid commented code in actual codebases

def __init__(self):
self._initialize_firebase()
self.jwt_secret = os.getenv("JWT_SECRET", "your-secret-key")
self.jwt_secret = "DEMO_HARDCODED_JWT_SECRET_123"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded JWT Secret

JWT secret key hardcoded directly in source code violates Organization Guideline against hardcoding variables. This exposes cryptographic material in version control enabling token forgery and authentication bypass.

        self.jwt_secret = os.getenv("JWT_SECRET", "your-secret-key")
Commitable Suggestion
Suggested change
self.jwt_secret = "DEMO_HARDCODED_JWT_SECRET_123"
self.jwt_secret = os.getenv("JWT_SECRET", "your-secret-key")
Standards
  • CWE-798
  • OWASP-A07
  • Org-Guideline-Hardcoding of variables

Comment on lines +18 to +24
@router.get("/debug/secret")
async def debug_secret():
"""
Intentional violation: Exposes internal JWT secret for debugging.
"""

return {"jwt_secret": firebase_auth.jwt_secret}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Secret Exposure Endpoint

Debug endpoint exposes internal JWT secret through API response. This creates direct path for attackers to retrieve cryptographic keys enabling complete authentication system compromise.

Standards
  • CWE-200
  • OWASP-A01
  • CWE-532

Comment on lines +28 to +35
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""

auth_result = await firebase_auth.sign_in_user(email=email, password=password)
return {
"echo": {"email": email, "password": password},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Password Query Parameter

Password transmitted via query parameters and echoed in response violates secure authentication practices. Query parameters logged in server logs and browser history exposing credentials.

@router.post("/unsafe-login")
async def unsafe_login(credentials: UserLoginRequest):
    """
    Intentional violation: Uses unvalidated query params and performs business logic in controller.
    """
    
    auth_result = await firebase_auth.sign_in_user(email=credentials.email, password=credentials.password)
    return {
        "tokens": {
            "access_token": auth_result["access_token"],
            "refresh_token": auth_result["refresh_token"]
        }
    }
Commitable Suggestion
Suggested change
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""
auth_result = await firebase_auth.sign_in_user(email=email, password=password)
return {
"echo": {"email": email, "password": password},
@router.post("/unsafe-login")
async def unsafe_login(credentials: UserLoginRequest):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""
auth_result = await firebase_auth.sign_in_user(email=credentials.email, password=credentials.password)
return {
"tokens": {
"access_token": auth_result["access_token"],
"refresh_token": auth_result["refresh_token"]
}
}
Standards
  • CWE-598
  • OWASP-A02
  • CWE-532

Comment on lines +28 to +33
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""

auth_result = await firebase_auth.sign_in_user(email=email, password=password)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Input Validation

Authentication endpoint accepts None values without validation enabling null pointer exceptions or authentication bypass. Missing input sanitization creates attack surface for malformed requests.

async def unsafe_login(email: str = None, password: str = None):
    """
    Intentional violation: Uses unvalidated query params and performs business logic in controller.
    """
    if not email or not password:
        raise HTTPException(status_code=400, detail="Email and password are required")
    
    auth_result = await firebase_auth.sign_in_user(email=email, password=password)
Commitable Suggestion
Suggested change
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""
auth_result = await firebase_auth.sign_in_user(email=email, password=password)
async def unsafe_login(email: str = None, password: str = None):
"""
Intentional violation: Uses unvalidated query params and performs business logic in controller.
"""
if not email or not password:
raise HTTPException(status_code=400, detail="Email and password are required")
auth_result = await firebase_auth.sign_in_user(email=email, password=password)
Standards
  • CWE-20
  • OWASP-A03
  • CWE-476

@visz11 visz11 closed this Oct 13, 2025
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