Repository navigation
fix(security): harden redirects, error views and debug output - #401
Conversation
- Keep the trailing-slash redirect on the current site - Require the 2FA code when signing in with a remember-me cookie - Escape the message in the bundled error views - Hide exception internals in JSON errors unless debugging - Treat APP_DEBUG="false" as off in the web error handler
|
Thanks for this @abdulmajidcse . The error-view escaping, the 1. Keep remember-me working for 2FA users (
|
- Keep remember-me signing in users with 2FA enabled - Decide whether a JSON error message is public by exception type - Check the trailing slash on the path and keep the query unchanged - Move the APP_DEBUG check into a shared app_debug() helper
|
@techmahedy Thanks for the review. All four are addressed in
The full suite and PHPStan pass. |
|
Thanks @abdulmajidcse, all four points are addressed in
One thing before merge: please update the PR title. It still says "2FA", and a squash merge would put that into the history. Optional: also reject control characters in |
Browsers drop tabs and newlines from a Location, so a target such as "/<tab>/evil.com" would still lead to another site.
|
@techmahedy Both are done in
The full suite and PHPStan pass locally. |
techmahedy
left a comment
There was a problem hiding this comment.
Thanks @abdulmajidcse, 2da65d9 covers it
Pull Request Checklist
Description
This fixes four security issues.
RouteLauncherredirected to the rawREQUEST_URI, so a URI starting with//or/\could send the browser to another site. The target now always starts with exactly one slash. The check runs on the raw path, the query string is kept unchanged, and a URI with control characters is never redirected, because browsers drop tabs and newlines from aLocation.$messageunescaped, and the 404 message includes the request path. They now escape it, as the 400 view already does.JsonErrorRendererreturnedfile,lineandtracein every environment. These now appear only whenAPP_DEBUGis on. With debugging off, the exception's own message is shown only for anHttpExceptionwith a 4xx status and for the CSRF mismatch; everything else saysSomething went wrong.APP_DEBUGas a string:WebErrorHandlertreated the string"false"as true, for example from a server environment variable, and showed the debug page. A newapp_debug()helper parses the value as a boolean, and both error paths use it.Behavior changes
"errors": []instead offile,lineandtrace.HttpExceptionor a CSRF mismatch saySomething went wrong, unless the caller passes explicit details./users/?next=/now redirects to/users?next=/, and/users?next=/no longer redirects.Testing
Checklist