net/mpd5: fix PPPoE Server remotely exploitable crash

This is security fix for PPPoE servers.

Insufficient validation of incoming PPPoE Discovery request
specially crafted by unauthenticated user might lead to unexpected
termination of the process. The problem affects mpd versions since 5.0.
Installations not using PPPoE server configuration were not affected.

Reported by:	paul & Yannick C at SourceForge
Tested by:	paul & Yannick C at SourceForge
Security:	f55921aa-10c9-11ec-8647-00e0670f2660
This commit is contained in:
Eugene Grosbein 2021-09-09 05:04:31 +07:00
parent 2c7d4d50c0
commit 1f6fcc264e
No known key found for this signature in database
GPG key ID: B0CD1AF226988B28
2 changed files with 35 additions and 1 deletions

View file

@ -2,7 +2,7 @@
PORTNAME= mpd
DISTVERSION= 5.9
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= SF/${PORTNAME}/Mpd5/Mpd-${PORTVERSION}
PKGNAMESUFFIX= 5

View file

@ -0,0 +1,34 @@
Index: src/pppoe.c
===================================================================
--- src/pppoe.c (revision 2420)
+++ src/pppoe.c (revision 2423)
@@ -1257,6 +1257,8 @@ PppoeListenEvent(int type, void *arg)
const struct pppoe_hdr *ph;
const struct pppoe_tag *tag;
+ u_int16_t length;
+
union {
u_char buf[sizeof(struct ngpppoe_init_data) + MAX_SESSION];
struct ngpppoe_init_data poeid;
@@ -1288,6 +1290,20 @@ PppoeListenEvent(int type, void *arg)
wh = (struct pppoe_full_hdr *)response;
ph = &wh->ph;
+
+ /* Sanity check */
+ length = ntohs(ph->length);
+ if (length > (size_t)sz - sizeof(struct pppoe_full_hdr)) {
+ Log(LG_PHYS, ("Ignored incoming PPPoE connection request "
+ "via %s for service \"%s\" from %s "
+ "due to bad length %hu > %u",
+ PIf->ifnodepath, session,
+ ether_ntoa((const struct ether_addr *)&wh->eh.ether_shost),
+ length,
+ (unsigned)((size_t)sz - sizeof(struct pppoe_full_hdr))));
+ return;
+ }
+
if ((tag = get_tag(ph, PTT_SRV_NAME))) {
size_t len = ntohs(tag->tag_len);
if (len >= sizeof(real_session))