Skip to content

[repo-monitor] Medium: api_base accepts non-HTTPS URLs — tokens sent over plaintext #4

@Liohtml

Description

@Liohtml

Summary

The api_base() builder method accepts any string with no HTTPS enforcement. Combined with tokens in query strings, a non-HTTPS base URL transmits API secrets in plaintext.

Location

  • File: src/lib.rs
  • Line(s): 157–159

Severity

Medium

Details

pub fn api_base(mut self, base: impl Into<String>) -> Self {
    self.api_base = base.into(); // no scheme validation
    self
}

If a caller passes an http:// URL (misconfiguration or local testing), the API token is transmitted in plaintext in the query string.

Suggested Fix

Validate the scheme at construction time:

pub fn api_base(mut self, base: impl Into<String>) -> Result<Self> {
    let base = base.into();
    if !base.starts_with("https://") {
        return Err(Error::InsecureBaseUrl(base));
    }
    self.api_base = base;
    Ok(self)
}

Automated finding by repo-monitor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions