Commit 5198573
http: fix use-after-free when freeParser is called during llhttp_execute
When pipelined requests arrive in one TCP segment, llhttp_execute()
parses them all in a single call. If a synchronous 'close' event
handler invokes freeParser() mid-execution, cleanParser() nulls out
parser state while llhttp_execute() is still on the stack, crashing on
the next callback.
Add an is_being_freed_ flag that freeParser() sets via
parser.markFreed() before cleaning state. Proxy::Raw checks the flag
before every callback and returns HPE_USER to abort execution early if
set.
PR-URL: #62095
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>1 parent a5b1be2 commit 5198573Copy full SHA for 5198573
3 files changed
+31-1Lines changed: 31 additions & 1 deletion
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- lib
- src
- test/parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
189 | 189 | |
190 | 190 | |
191 | 191 | |
192 | | - |
193 | 192 | |
| 193 | + |
194 | 194 | |
195 | 195 | |
196 | 196 | |
|
Collapse file
+7Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
628 | 628 | |
629 | 629 | |
630 | 630 | |
| 631 | + |
| 632 | + |
631 | 633 | |
632 | 634 | |
633 | 635 | |
| ||
1012 | 1014 | |
1013 | 1015 | |
1014 | 1016 | |
| 1017 | + |
1015 | 1018 | |
1016 | 1019 | |
1017 | 1020 | |
| ||
1056 | 1059 | |
1057 | 1060 | |
1058 | 1061 | |
| 1062 | + |
1059 | 1063 | |
1060 | 1064 | |
1061 | 1065 | |
| ||
1075 | 1079 | |
1076 | 1080 | |
1077 | 1081 | |
| 1082 | + |
| 1083 | + |
| 1084 | + |
1078 | 1085 | |
1079 | 1086 | |
1080 | 1087 | |
|
Collapse file
test/parallel/test-http-parser-freed-during-execute.js
Copy file name to clipboard+23Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
0 commit comments