Skip to content

CORS origin matching uses string substitution instead of URI parsing #27

@HellFelix

Description

@HellFelix

The alternate CORS origin is derived by calling String::replace on the raw API_ENDPOINT_SERVER value. This is not URI-aware and replaces all occurrences of the substring. A hostname such as http://localhost-staging.fsek.se:1443 would produce http://127.0.0.1-staging.fsek.se:1443 as the alternate allowed origin.

File: rustsystem-trustauth/src/lib.rs:196-200

let alt = if API_ENDPOINT_SERVER.contains("127.0.0.1") {
    API_ENDPOINT_SERVER.replace("127.0.0.1", "localhost")
} else {
    API_ENDPOINT_SERVER.replace("localhost", "127.0.0.1")
};

Fix: Parse API_ENDPOINT_SERVER as a URI and manipulate only the host component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    mediumMedium prioritysecurityRelated to safety of the system

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions