mirror of
https://repo.or.cz/socat.git
synced 2025-01-08 22:12:33 +00:00
fixed a stack overflow vulnerability with long command line args
This commit is contained in:
parent
5df0e4a3d9
commit
c576712ebd
4 changed files with 82 additions and 4 deletions
9
CHANGES
9
CHANGES
|
@ -1,4 +1,13 @@
|
||||||
|
|
||||||
|
security:
|
||||||
|
fixed a stack overflow vulnerability that occurred when command
|
||||||
|
line arguments (whole addresses, host names, file names) were longer
|
||||||
|
than 512 bytes.
|
||||||
|
Note that this could only be exploited when an attacker was able to
|
||||||
|
inject data into socat's command line.
|
||||||
|
Full credits to Felix Gröbert, Google Security Team, for finding and
|
||||||
|
reporting this issue
|
||||||
|
|
||||||
####################### V 2.0.0-b3:
|
####################### V 2.0.0-b3:
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* source: nestlex.c */
|
/* source: nestlex.c */
|
||||||
/* Copyright Gerhard Rieger 2006-2007 */
|
/* Copyright Gerhard Rieger 2006-2010 */
|
||||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
/* a function for lexical scanning of nested character patterns */
|
/* a function for lexical scanning of nested character patterns */
|
||||||
|
@ -221,7 +221,7 @@ int nestlex(const char **addr, /* input string; aft points to end token */
|
||||||
}
|
}
|
||||||
*out++ = c;
|
*out++ = c;
|
||||||
--*len;
|
--*len;
|
||||||
if (len == 0) {
|
if (*len == 0) {
|
||||||
*addr = in;
|
*addr = in;
|
||||||
*token = out;
|
*token = out;
|
||||||
return -1; /* output overflow */
|
return -1; /* output overflow */
|
||||||
|
@ -233,7 +233,7 @@ int nestlex(const char **addr, /* input string; aft points to end token */
|
||||||
/* just a simple char */
|
/* just a simple char */
|
||||||
*out++ = c;
|
*out++ = c;
|
||||||
--*len;
|
--*len;
|
||||||
if (len == 0) {
|
if (*len == 0) {
|
||||||
*addr = in;
|
*addr = in;
|
||||||
*token = out;
|
*token = out;
|
||||||
return -1; /* output overflow */
|
return -1; /* output overflow */
|
||||||
|
|
69
test.sh
69
test.sh
|
@ -10514,6 +10514,75 @@ t TCP
|
||||||
# -U exec1
|
# -U exec1
|
||||||
|
|
||||||
|
|
||||||
|
# socat up to 1.7.1.2 and from 2.0.0-b1 to 2.0.0-b3 had a stack overflow vulnerability that occurred when
|
||||||
|
# command line arguments (whole addresses, host names, file names) were longer
|
||||||
|
# than 512 bytes.
|
||||||
|
NAME=HOSTNAMEOVFL
|
||||||
|
case "$TESTS" in
|
||||||
|
*%functions%*|*%bugs%*|*%security%*|*%socket%*|*%$NAME%*)
|
||||||
|
TEST="$NAME: stack overflow on overly long host name"
|
||||||
|
# provide a long host name to TCP-CONNECT and check socats exit code
|
||||||
|
if ! eval $NUMCOND; then :; else
|
||||||
|
tf="$td/test$N.stdout"
|
||||||
|
te="$td/test$N.stderr"
|
||||||
|
tdiff="$td/test$N.diff"
|
||||||
|
da="test$N $(date) $RANDOM"
|
||||||
|
# prepare long data - perl might not be installed
|
||||||
|
rm -f "$td/terst$N.dat"
|
||||||
|
i=0; while [ $i -lt 64 ]; do echo -n "AAAAAAAAAAAAAAAA" >>"$td/test$N.dat"; i=$((i+1)); done
|
||||||
|
CMD0="$SOCAT $opts TCP-CONNECT:$(cat "$td/test$N.dat"):$PORT STDIO"
|
||||||
|
printf "test $F_n $TEST... " $N
|
||||||
|
$CMD0 </dev/null 1>&0 2>"${te}0"
|
||||||
|
rc0=$?
|
||||||
|
if [ $rc0 -lt 128 ] || [ $rc0 -eq 255 ]; then
|
||||||
|
$PRINTF "$OK\n"
|
||||||
|
numOK=$((numOK+1))
|
||||||
|
else
|
||||||
|
$PRINTF "$FAILED\n"
|
||||||
|
echo "$CMD0"
|
||||||
|
cat "${te}0"
|
||||||
|
numFAIL=$((numFAIL+1))
|
||||||
|
fi
|
||||||
|
fi # NUMCOND
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
N=$((N+1))
|
||||||
|
|
||||||
|
#set -vx
|
||||||
|
# socat up to 1.7.1.2 and from 2.0.0-b1 to 2.0.0-b3 had a stack overflow vulnerability that occurred when
|
||||||
|
# command line arguments (whole addresses, host names, file names) were longer
|
||||||
|
# than 512 bytes.
|
||||||
|
NAME=FILENAMEOVFL
|
||||||
|
case "$TESTS" in
|
||||||
|
*%functions%*|*%bugs%*|*%security%*|*%openssl%*|*%$NAME%*)
|
||||||
|
TEST="$NAME: stack overflow on overly long file name"
|
||||||
|
# provide a 600 bytes long key file option to SSL-CONNECT and check socats exit code
|
||||||
|
if ! eval $NUMCOND; then :; else
|
||||||
|
tf="$td/test$N.stdout"
|
||||||
|
te="$td/test$N.stderr"
|
||||||
|
tdiff="$td/test$N.diff"
|
||||||
|
da="test$N $(date) $RANDOM"
|
||||||
|
i=0; while [ $i -lt 64 ]; do echo -n "AAAAAAAAAAAAAAAA" >>"$td/test$N.dat"; i=$((i+1)); done
|
||||||
|
CMD0="$SOCAT $opts OPENSSL:localhost:$PORT,key=$(cat "$td/test$N.dat") STDIO"
|
||||||
|
printf "test $F_n $TEST... " $N
|
||||||
|
$CMD0 </dev/null 1>&0 2>"${te}0"
|
||||||
|
rc0=$?
|
||||||
|
if [ $rc0 -lt 128 ] || [ $rc0 -eq 255 ]; then
|
||||||
|
$PRINTF "$OK\n"
|
||||||
|
numOK=$((numOK+1))
|
||||||
|
else
|
||||||
|
$PRINTF "$FAILED\n"
|
||||||
|
echo "$CMD0"
|
||||||
|
cat "${te}0"
|
||||||
|
numFAIL=$((numFAIL+1))
|
||||||
|
fi
|
||||||
|
fi # NUMCOND
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "summary: $((N-1)) tests; $numOK ok, $numFAIL failed, $numCANT could not be performed"
|
echo "summary: $((N-1)) tests; $numOK ok, $numFAIL failed, $numCANT could not be performed"
|
||||||
|
|
|
@ -142,7 +142,7 @@ int xioclose(xiofile_t *file) {
|
||||||
} else {
|
} else {
|
||||||
result = xioclose1(&file->stream);
|
result = xioclose1(&file->stream);
|
||||||
}
|
}
|
||||||
if (xfd->stream.subthread != 0) {
|
if (xfd->tag != XIO_TAG_INVALID && xfd->stream.subthread != 0) {
|
||||||
Pthread_join(xfd->stream.subthread, NULL);
|
Pthread_join(xfd->stream.subthread, NULL);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue