Skip to content

Commit 27f996d

Browse files
committed
Remove crtl chars from HTTP header (3.0)
... which fixes #2337
1 parent 6d714d6 commit 27f996d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

testssl.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,9 +2252,14 @@ run_http_header() {
22522252
# Quit on first empty line to catch 98% of the cases. Next pattern is there because the SEDs tested
22532253
# so far seem not to be fine with header containing x0d x0a (CRLF) which is the usual case.
22542254
# So we also trigger also on any sign on a single line which is not alphanumeric (plus _)
2255-
sed -e '/^$/q' -e '/^[^a-zA-Z_0-9]$/q' $HEADERFILE >$HEADERFILE.tmp
2255+
#
2256+
# Also we use tr here to remove any crtl chars which the server side offers --> possible security problem
2257+
# Only allowed now is LF + CR. See #2337
2258+
# awk, see above, doesn't seem to care
2259+
sed -e '/^$/q' -e '/^[^a-zA-Z_0-9]$/q' $HEADERFILE | tr -d '\000-\011\013\014\016-\037' >$HEADERFILE.tmp
2260+
sed -e '/^$/q' -e '/^[^a-zA-Z_0-9]$/q' $HEADERFILE | tr -d '\000-\010\013\014\016-\037' >$HEADERFILE.tmp
22562261
# Now to be more sure we delete from '<' or '{' maybe with a leading blank until the end
2257-
sed -e '/^ *<.*$/d' -e '/^ *{.*$/d' $HEADERFILE.tmp >$HEADERFILE
2262+
sed -e '/^ *<.*$/d' -e '/^ *{.*$/d' $HEADERFILE.tmp >$HEADERFILE
22582263
debugme echo -e "---\n $(< $HEADERFILE) \n---"
22592264

22602265
HTTP_STATUS_CODE=$(awk '/^HTTP\// { print $2 }' $HEADERFILE 2>>$ERRFILE)

0 commit comments

Comments
 (0)