Repository navigation
Commit 6eff549
committed
ADFA-5241: Close the response-splitting hole the charset parameter left open
safeType refused a value carrying a control character, but the refusal
was read back out of its return value -- OCTET_STREAM with no charset --
and a control character inside the charset parameter defeated that:
declaredCharset re-parsed the original string, found a charset, so
"refused" was never true, and headerValue appended the CRLF-bearing
value verbatim. WebServer writes the result with println, so
text/html; charset=x<CR><LF><CR><LF><script>alert(1)</script>
split the reply into two HTTP responses with an attacker-chosen body --
the one thing this class exists to prevent. The two existing "refused,
not repaired" tests put their control character in the type segment or a
note= parameter, so neither could see it.
Refusal is asked now, not inferred: one isUntrustworthy() consulted by
both typeAndCharset and headerValue. That also stops a legitimately
stored application/octet-stream; name=file.bin from being mistaken for a
refusal and losing its parameters.
The charset is the one value that skipped quoteIfNeeded, so a stored
charset="utf-8; x=y" -- whose quotes parameters() strips -- came back out
as a charset plus a smuggled second parameter. It goes through the same
quoting as every other parameter value now.
Four tests, three of which fail against the previous logic. 84 common
tests pass.
Found in review of PR #1725.1 parent 8769776 commit 6eff549
2 files changed
Lines changed: 68 additions & 4 deletions
File tree
- common/src
- main/java/com/itsaky/androidide/utils
- test/java/com/itsaky/androidide/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
71 | 89 | | |
72 | 90 | | |
73 | 91 | | |
| |||
205 | 223 | | |
206 | 224 | | |
207 | 225 | | |
208 | | - | |
209 | 226 | | |
210 | | - | |
211 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
212 | 231 | | |
213 | 232 | | |
| 233 | + | |
214 | 234 | | |
215 | 235 | | |
216 | 236 | | |
217 | 237 | | |
218 | 238 | | |
219 | 239 | | |
220 | 240 | | |
221 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
222 | 245 | | |
223 | 246 | | |
224 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
139 | 180 | | |
0 commit comments