Skip to content

fix: decode paths before matching#245

Merged
mcollina merged 4 commits intofastify:mainfrom
kamilmysliwiec:fix/decode-paths-before-matching
Jan 3, 2026
Merged

fix: decode paths before matching#245
mcollina merged 4 commits intofastify:mainfrom
kamilmysliwiec:fix/decode-paths-before-matching

Conversation

@kamilmysliwiec
Copy link
Copy Markdown
Contributor

@kamilmysliwiec kamilmysliwiec commented Dec 29, 2025

Fix on the NestJS side nestjs/nest#16135

instance.use('/admin', function (req, _res, next) {
  // check headers here to ensure caller is allowed to access this endpoint
  // <auth logic>
  next()
})

if someone calls your-api:3000/%61dmin, no middleware will be triggered, even though the /admin endpoint (handler) would be executed (as find-my-way decode URLs before matching routes)

credit for reporting this issue goes to Hacktron AI

Checklist

Comment thread lib/engine.js Outdated
Copy link
Copy Markdown
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

can you run npm run lint:fix?

@gurgunday gurgunday requested review from a team January 2, 2026 19:44
@mcollina
Copy link
Copy Markdown
Member

mcollina commented Jan 3, 2026

@kamilmysliwiec in the future, please report vulnerability privately.

@Eomm Eomm changed the title fix: decode paths before matching (vulnerability) fix: decode paths before matching Jan 3, 2026
@fastify fastify deleted a comment from rootxharsh Jan 3, 2026
Signed-off-by: Manuel Spigolon <behemoth89@gmail.com>
@kamilmysliwiec
Copy link
Copy Markdown
Contributor Author

@mcollina i was informed that the vulnerability has already been submitted privately - i wasn't the one who found it

@Eomm
Copy link
Copy Markdown
Member

Eomm commented Jan 3, 2026

@mcollina i was informed that the vulnerability has already been submitted privately - i wasn't the one who found it

https://github.com/fastify/fastify/blob/main/SECURITY.md#publication

Within 90 days after the triage date, the vulnerability must be made public.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit d44cd56 into fastify:main Jan 3, 2026
14 checks passed
mcollina added a commit to fastify/fastify-express that referenced this pull request Jan 3, 2026
URL-encoded paths could bypass middleware (e.g., /%61dmin would bypass
middleware registered on /admin). This uses FindMyWay.sanitizeUrlPath()
to decode URLs before Express matches middleware, consistent with the
fix in fastify/middie#245.
Eomm added a commit to fastify/fastify-express that referenced this pull request Jan 5, 2026
* fix: decode paths before matching

URL-encoded paths could bypass middleware (e.g., /%61dmin would bypass
middleware registered on /admin). This uses FindMyWay.sanitizeUrlPath()
to decode URLs before Express matches middleware, consistent with the
fix in fastify/middie#245.

* fix: handle express handlers (#175)

---------

Co-authored-by: Manuel Spigolon <manuel.spigolon@nearform.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants