Skip to content

Commit 1296279

Browse files
authored
Merge pull request #2554 from drwetter/noCtrlCharInHeader_3.0
No ctrl char in header (3.0)
2 parents 6ce7b64 + 27f996d commit 1296279

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

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

0 commit comments

Comments
 (0)