Commit 8a59af2
doc: correct unsafe URL example in http docs
The previous documentation example for converting `request.url` to an
`URL` object was unsafe, as it could allow a server crash through
malformed URL inputs and potentially enable host header attacks.
This commit revises the example to use string concatenation over the
usage of the `baseUrl` and removes the usage of the `req.headers.host`
as the authority part of the url, mitigating both the crash and security
risks by ensuring the host part of the URL remains controlled and
predictable.
Fixes #52494
Co-authored-by: @astlouisf
Co-authored-by: @samhh
PR-URL: #52555
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>1 parent ec113ba commit 8a59af2
1 file changed
+11
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2886 | 2886 | | |
2887 | 2887 | | |
2888 | 2888 | | |
2889 | | - | |
| 2889 | + | |
2890 | 2890 | | |
2891 | 2891 | | |
2892 | | - | |
2893 | | - | |
| 2892 | + | |
2894 | 2893 | | |
2895 | 2894 | | |
2896 | 2895 | | |
2897 | | - | |
| 2896 | + | |
2898 | 2897 | | |
2899 | | - | |
2900 | | - | |
| 2898 | + | |
| 2899 | + | |
2901 | 2900 | | |
2902 | 2901 | | |
2903 | 2902 | | |
2904 | | - | |
| 2903 | + | |
2905 | 2904 | | |
2906 | | - | |
| 2905 | + | |
2907 | 2906 | | |
2908 | 2907 | | |
2909 | 2908 | | |
2910 | 2909 | | |
2911 | 2910 | | |
2912 | 2911 | | |
2913 | 2912 | | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
2914 | 2917 | | |
2915 | 2918 | | |
2916 | 2919 | | |
| |||
0 commit comments