You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No PKCE Implementation in OAuth Authorization Code Flow #87
The OAuth flow uses the state parameter for CSRF protection but does not implement Proof Key for Code Exchange (PKCE). ASVS 10.1.2 specifically names PKCE code_verifier as a client-generated secret that should be transaction-specific and session-bound. Without PKCE, the authorization code itself is the sole bearer credential for obtaining tokens, vulnerable to code interception attacks via Referer header leak, browser history, open redirector, malicious browser extensions, or network-level interception.
Details
Affected Files and Lines:
src/asfquart/generics.py:48-101 - OAuth flow without PKCE
The flow lacks PKCE protection, making authorization codes vulnerable to interception.
Recommended Remediation
Implement PKCE (RFC 7636) if the ASF OAuth service supports it:
# On login initiationcode_verifier=secrets.token_urlsafe(64)
code_challenge=base64.urlsafe_b64encode(
hashlib.sha256(code_verifier.encode()).digest()
).rstrip(b'=').decode()
# Store code_verifier in pending_statespending_states[state]['code_verifier'] =code_verifier# Include in authorization requestoauth_url= (
f"{OAUTH_URL_AUTHORIZE}?"f"response_type=code&"f"client_id={CLIENT_ID}&"f"redirect_uri={redirect_uri}&"f"state={state}&"f"code_challenge={code_challenge}&"f"code_challenge_method=S256"
)
# On token exchangecode_verifier=state_data['code_verifier']
token_params= {
'code': code,
'code_verifier': code_verifier,
# ... other params
}
Activity
andrewmusselman commentedon Mar 31, 2026
Notes from
atrtriage: possibly this could go on MFA server