transform_reverse checks to see if the incoming message is a multiple
of the block cipher block size. If the message fails this check, it
sets *errmsg but it fails to return. Instead, it proceeds to attempt
to decrypt it. This will involve a buffer read/write overrun.
It transform_reverse fails to check to see if the incoming message is
long enough to contain the IV, MAC and padding. This can easily be
exploited to cause secnet to segfault.
buffer_unprepend should check that the buffer has enough data in it to
unprepend. With the other patches, this should be irrelevant, but it
turns various other potential read overrun bugs into crashes.
site_incoming should check that the incoming message is long enough.
Again, without this, this is an buffer read overrun or possibly a
segfault.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
const struct comm_addr *source)
{
struct site *st=sst;
+
+ if (buf->size < 12) return False;
+
uint32_t dest=ntohl(*(uint32_t *)buf->start);
if (dest==0) {
return 1;
}
+ if (buf->size < 4 + 16 + 16) {
+ *errmsg="msg too short";
+ return 1;
+ }
/* CBC */
memset(iv,0,16);
/* Assert bufsize is multiple of blocksize */
if (buf->size&0xf) {
*errmsg="msg not multiple of cipher blocksize";
+ return 1;
}
serpent_encrypt(&ti->cryptkey,iv,iv);
for (n=buf->start; n<buf->start+buf->size; n+=16)
void *buf_unprepend(struct buffer_if *buf, int32_t amount) {
void *p;
+ if (buf->size < amount) return 0;
p=buf->start;
buf->start+=amount;
buf->size-=amount;