-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return correct HTTP status for disallowed HTTP methods
Make sure that we return the correct HTTP status for disallowed HTTP methods: - For pages that do not exist, return 404. - For pages that do exist but do not support the requested method, return 405. A fact of life on the Internet is that public sites are constantly being probed for vulnerabilities or misconfigurations of common frameworks. These requests often attempt to POST or PUT to irrelevant endpoints. Before this patch, we were logging something like this for each such request: ``` 2024-12-08T13:52:31.557Z 48395885-e0a7-4cda-a750-3d5267bb20d1 ERROR Error: You made a POST request to "/wp-admin/admin-ajax.php" but did not provide an `action` for route "routes/$", so there is no way to handle the request. at sa (/var/task/index.cjs:49:10806) at u (/var/task/index.cjs:48:47306) at c (/var/task/index.cjs:48:46995) at Object.s [as query] (/var/task/index.cjs:48:46027) at Nvt (/var/task/index.cjs:64:17420) at /var/task/index.cjs:64:15716 at /var/task/index.cjs:137:7577 at Runtime.hOr [as handler] (/var/task/index.cjs:2326:74163) 2024-12-08T13:52:31.616Z 48395885-e0a7-4cda-a750-3d5267bb20d1 ERROR Error: Invariant failed at Ln (/var/task/index.cjs:318:39742) at lm (/var/task/index.cjs:340:1264) at O2 (/var/task/index.cjs:340:1930) at Blr (/var/task/index.cjs:340:2261) at y8e (/var/task/index.cjs:192:3805) at rZ (/var/task/index.cjs:192:4617) at gu (/var/task/index.cjs:192:7257) at rZ (/var/task/index.cjs:192:6651) at gu (/var/task/index.cjs:192:7257) at rZ (/var/task/index.cjs:192:6651) 2024-12-08T13:52:31.619Z 48395885-e0a7-4cda-a750-3d5267bb20d1 ERROR Error: Invariant failed at Ln (/var/task/index.cjs:318:39742) at lm (/var/task/index.cjs:340:1264) at O2 (/var/task/index.cjs:340:1930) at Blr (/var/task/index.cjs:340:2261) at y8e (/var/task/index.cjs:192:3805) at rZ (/var/task/index.cjs:192:4617) at gu (/var/task/index.cjs:192:7257) at rZ (/var/task/index.cjs:192:6651) at gu (/var/task/index.cjs:192:7257) at rZ (/var/task/index.cjs:192:6651) ``` Don't treat these as server errors and don't log them. Do return the correct HTTP status.
- Loading branch information
Showing
5 changed files
with
24 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters