fix: close two CSRF origin-check security gaps
- Extend origin check to all /api/ requests (not just state-changing methods), closing the GET/HEAD/OPTIONS bypass that allowed cross-origin reads - origin_allowed() now returns False when both Origin and Referer headers are absent, preventing script-initiated requests from bypassing the check - Update AGENTS.md and README.md to document the changes
This commit is contained in:
@@ -156,7 +156,7 @@ def origin_allowed(request: Request) -> bool:
|
||||
parsed = urlparse(referer)
|
||||
ref_origin = f"{parsed.scheme}://{parsed.netloc}".rstrip("/")
|
||||
return ref_origin == expected_origin or ref_origin in TRUSTED_ORIGINS
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_state_changing(method: str) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user