DragonFlyBSD all versions FireWire IOCTL kernel integer overflow information disclousure Nov 15 2006 12:54PM
Rodrigo Rubira Branco (BSDaemon) (rodrigo kernelhacking com)

Kernel Hacking: If i really know, i can hack

GPG KeyID: 5E90CA19

Message sent using UebiMiau 2.7.2

DragonFlyBSD all versions FireWire IOCTL kernel integer overflow information disclousure

This bug has been specially discovered for the Month of Kernel Bugs and to
the Hackers to Hackers Conference III (http://www.h2hc.org.br/en/).


Firewire device is enabled by default in the GENERIC kernel. It defines
an IOCTL function which can be malicious called passing a negative buffer
lenght value. This value will bypass the lenght check (because the value
is negative) and will be used in a copyout operation.

Systems Affected

FreeBSD all versions
NetBSD all versions
DragonFly all versions
TrustedBSD* all versions


This is a kernel bug and the system can be compromised by local users and
important system informations can be discloused (basically, a mem dump ;) )


Firewire interface can be tunned. It provides an ioctl function receiving
many parameters that can be changed.

The follow is a code fragment from (FreeBSD - dev/firewire/fwdev.c (fw_ioctl function) || DragonFlyBSD bus/firewire/fwdev.c (fw_ioctl function) || NetBSD - dev/ieee1394/fwdev.c (FW_IOCTL function)) file:

if (crom_buf->len < len)
len = crom_buf->len;
crom_buf->len = len;

err = copyout(ptr, crom_buf->ptr, len);

We control the crom_buf->len (it's passed as argument to the ioctl function)
so, passing it as a negative value will bypass this if statement (our value
is minor than the default one).

So, our value is used in a copyout function. ptr is defined before this
copyout as:
if ( fwdev == NULL ) {
ptr = malloc(CROMSIZE, M_FW, M_WAITOK);
} else {
ptr = (void *)&fwdev->csrrom[0];

This information disclousure lead an attacker dump all the system memory.


Attached in this advisory a patch for the FreeBSD 5.5 (it's pretty simple, so, just need to be little changed to the other BSD's)


11/15/2006 - Advisory Public Disclousure (sorry for the developers, but we
are just respecting the Month of Kernel Bugs Timelife)


Filipe Balestra <filipe (at) balestra.com (dot) br [email concealed]> and Rodrigo Rubira Branco
(BSDaemon) <rodrigo (at) kernelhacking (dot) com [email concealed]> for the discovering, analysis
and patch.

Contact Information

You can reach the authors of this advisory by mail or visiting some
http://www.balestra.com.br -> Personal Website of Filipe
http://www.risesecurity.org -> RISE Security Research (Rodrigo is member of the RISE Security Team)
http://www.kernelhacking.com/rodrigo -> Personal Website of Rodrigo


http://www.kernelhacking.com/bsdadv1.txt -> Actual version of the advisory
http://www.risesecurity.org/RISE-2006002.txt -> Related issue

Disclaimer (taken from teso-team)

This advisory does not claim to be complete or to be usable for any
purpose. Especially information on the vulnerable systems may be
inaccurate or wrong. The supplied exploit is not to be used for malicious
purposes, but for educational purposes only.

This advisory is free for open distribution in unmodified form.
£W¿oE  y%$Ý«`ÙwvBHb?ãØpÊOÙ?,? ?Ý}{7dvg53{Çñ£D ªHT :詨h AÐPÐRñ'
þøÜ8ík3ê'fÀå ×¢h¯.
af'¶ñøL=>Op:¸?B¤ âæ\ÔÊ?ÏÛ7·w?[-?}¢¡óKdÉ68e s^?iÀr:?é?RL$L?P2?@ÊïP ke9"A%þ?`?óo?ËÑØÑD¨?û-¾á?¦)NfÞ<ÄÕ®LÇ?Þ§8áTÔ?ÃLX¼Á¸Û¤pn?0aiæ((ÕÕL×
?tÅ&PîͬãÂÒ&ÂJg§ i?=ýG(&o²ëæ?OÎÙ{Ò侩Aë?'£aQ?Ô=: ~DÇzOÎÀ0cùºÌ¤º¨?.¤mÒ®4ä1
%?J'J×Ù©Û9êj~âDXé=[F ²º¨èRzQ´ý~¥Dlÿ7}¹?\??í6®.KÎ"ð?ÌØGJR§N²ÏpÊr?w?(g ?»PUcáæ?E9?Ç9
Fª 6#òT0??)?»t¯øÊäm¨?|?×~Jq>½×D?§ ¨G}D Z?Ôö4ÛÃC5{Jf^;ÿêË?v;÷ë¯×£\*
??a¥3Zî-º?¥{Ñ)i Â?ê?3Tϯ~?àÐêå¹xH¬%ä$ð??uÄõ¾c]?Eq(d?Y4R×)?.¹×²b?ÎͼÉqåè¢ì ðKuDQ1j?C ÁWg ìÅhÉ?SÈ"­¯ÓÍ;ׯS>øý~?Þ׺WOÔe¼µ{ëÆÞðííeºqoçÀl÷o]Öízú?|î??Æ4?h?ÑK½
Â+©5HÁÝÕwæ6???ïB$Td¾È?sá2jêÙkÒAAk3ó©U}zyÓ¦w4n0 )ÙDZ?ÑJ8\ÝeÙÛ?þ??/????*)^n?Õ³â=¨%¨Àþõ?­¤sj^ߧ4> Áã?b´/ V2?ùjoB=ìP|?]?·ë7]=R? ÌtnVþ>±Ë¨uGSnÄ,ç&VþMp?ɏl ºëfz¿ÔS\?A?ì)!ïH%+¦+B±uFÐå< ¼?´}?>Z? ð»:3r¤i·N$Ö^1¢Luj ?Ò
??ÐÈ û???l;å0oé:Hµa0&l#j7ÖPq@µÈÜ_??Fd@Öê¢)t$ Áû²;Ò:=? v?n#iáC½??ß©ÁtÁÔàÒ´?ÖFº?ï¾¼éîpo?öÚAÚż0;îPörÃE
ú'??2ÚgQô6:ù MÆ£?mw?¢]n[ÆÓèrêNhµï?o·ýn?©«Å¼éÐeà?¿?!ø£®øbZ]=×ùÜeq
?X Q?BM ðÞPìÄ}ÜáÚEæô? Ø<ú(û |È4z?Rãª÷þZYð
b?iGjë»ÞÀbô £ª6?¶h>·[ù£ê¨?»bR«£7·m»X±¥?,E?Ã?f·©Ñ5´¶®*%qfF7¤qÉ&Ð. öÛ¼m^ª¿
}á?è¯äì?¯/?ùóïß~÷ìç_½üÊ¿_¦¿ýù÷skü--- dev/firewire/fwdev.c.orig Fri Oct 13 13:12:49 2006
+++ dev/firewire/fwdev.c Fri Oct 13 13:13:42 2006
@@ -712,7 +712,7 @@ out:
len = fwdev->rommax - CSRROMOFF + 4;
- if (crom_buf->len < len)
+ if (crom_buf->len < len && crom_buf->len > 0)
len = crom_buf->len;
crom_buf->len = len;
£?ÀËÌÀ$xd?ᄌ §$×2$q&§è$?$g¸Fk<ÕÕÕUHI-ÓOË,J-bý´r W/Y/¿(3Ó­(SÁ?¹DÁÐ?¬ ¬L,? ̸´µµ±jC×alebÑáà  knh¤c® 
]çà  _77mkÊZ.]NÎÌ4d ¢ø¤Ò4];V ©É¥SNAMMUØNÁ@l7ÄjI°UpÇ¡ê³U+è°gfe?$,?né1ÌOó{/RôF*¦ä¬zÏ·W~>?È0?ÒQ

[ reply ]


Privacy Statement
Copyright 2010, SecurityFocus