{"record":{"id":"0e46fa280aef2339","repo":"astrid-runtime/astrid","slug":"cors-origin-raw-carries-userinfo-user-passwor","errorCode":null,"errorMessage":"CORS origin {raw:?} carries userinfo (user:password); browsers strip it before sending `Origin:` so this can never match","messagePattern":"CORS origin (.+?) carries userinfo \\(user:password\\); browsers strip it before sending `Origin:` so this can never match","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-gateway/src/config.rs","lineNumber":203,"sourceCode":"/// match a real preflight; rejecting it here is what makes that\n/// surfacable.\nfn validate_cors_origin(raw: &str) -> anyhow::Result<()> {\n    let parsed = url::Url::parse(raw)\n        .map_err(|e| anyhow::anyhow!(\"CORS origin {raw:?} doesn't parse as a URL: {e}\"))?;\n    match parsed.scheme() {\n        \"http\" | \"https\" => {},\n        other => anyhow::bail!(\n            \"CORS origin {raw:?} uses scheme {other:?}; only http/https are valid for browser origins\"\n        ),\n    }\n    if parsed.host_str().is_none() {\n        anyhow::bail!(\"CORS origin {raw:?} has no host component\");\n    }\n    // Browsers strip userinfo before sending `Origin:`, so a config\n    // entry with embedded credentials can never match a real\n    // preflight. Reject so operators don't silently misconfigure.\n    if !parsed.username().is_empty() || parsed.password().is_some() {\n        anyhow::bail!(\n            \"CORS origin {raw:?} carries userinfo (user:password); browsers strip it before sending `Origin:` so this can never match\"\n        );\n    }\n    if parsed.path() != \"\" && parsed.path() != \"/\" {\n        anyhow::bail!(\n            \"CORS origin {raw:?} carries a path ({:?}); origins are scheme+host+port only\",\n            parsed.path()\n        );\n    }\n    if parsed.query().is_some() || parsed.fragment().is_some() {\n        anyhow::bail!(\n            \"CORS origin {raw:?} carries a query/fragment; origins are scheme+host+port only\"\n        );\n    }\n    // Disallow trailing-slash forms — browsers send `https://app.example`\n    // (no slash) in `Origin:` and the response header is byte-matched.\n    if raw.ends_with('/') {\n        anyhow::bail!(","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/config.rs#L185-L221","documentation":"Validation guard in validate_cors_origin: the origin embeds user:password credentials; browsers strip userinfo before sending Origin:, so such an entry can never match a real preflight and is rejected at boot to avoid silent misconfiguration.","triggerScenarios":"Thrown at crates/astrid-gateway/src/config.rs:203 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the user:password portion from the origin entry","Keep credentials out of CORS origins entirely — use auth headers instead","If the URL came from generated config, fix the generator to emit bare scheme://host[:port]"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}