CVE-2026-136131
hping3 Out-of-Bounds Write in display_ipopt() via IP Record Route Option
Out-of-Bounds Write in display_ipopt() via IP Record Route Option (old_rr buffer overflow)
Teknik Rapor
CVE-2026-136131 -- Out-of-Bounds Write in display_ipopt() via Record Route
hping2 display_ipopt() içinde old_rr tamponuna bellek dışı yazma (CWE-787)
Out-of-bounds write into old_rr in hping2 display_ipopt() (CWE-787)
Türkçe Versiyon
Özet
hping2 kod tabanındaki display_ipopt.c dosyasında yer alan display_ipopt() fonksiyonu, alınan IP paketindeki doğrulanmamış bir bayttan okunan uzunluk değerini kullanarak saldırgan kontrollü veriyi 40 baytlık sabit boyutlu global bir tampona (old_rr[MAX_IPOPTLEN]) kopyalamaktadır. Kopyalama uzunluğu yalnızca 0xFF ile sınırlıdır; MAX_IPOPTLEN ile veya IP başlığında kalan gerçek uzunlukla sınırlandırılmamaktadır. Bu durum, tamponun ötesine yaklaşık 211 bayta kadar bellek dışı yazma (out-of-bounds write) yapılmasına olanak tanır. Yazılan verinin hem uzunluğu hem de içeriği paketi gönderen kişi tarafından tamamen kontrol edilebilir.
Zafiyet Bilgileri
| Alan | Değer |
|---|---|
| CVE | CVE-2026-136131 |
| CWE | CWE-787 (Out-of-bounds Write), ilişkili: CWE-20 (Improper Input Validation) |
| Bileşen | display_ipopt.c, display_ipopt() fonksiyonu |
| Tetiklenme yolu | wait_packet() → display_ipopt() (waitpacket.c) |
| CVSS Sürümü | 4.0 |
| CVSS Skoru | 6.0 (MEDIUM) |
| CVSS Vektörü | CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N |
Etkilenen Kod
display_ipopt.c:
static int old_rrlen;
static char old_rr[MAX_IPOPTLEN]; // MAX_IPOPTLEN == 40 (hping2.h)
...
case IPOPT_RR:
j = *++cp; /* seçenek uzunluk baytı — ham, saldırgan kontrollü (0–255) */
i = *++cp; /* seçenek işaretçi baytı — ham, saldırgan kontrollü (0–255) */
hlen -= 2;
if (i > j)
i = j;
i -= IPOPT_MINOFF; /* IPOPT_MINOFF == 4 */
if (i <= 0)
continue;
...
old_rrlen = i;
memcpy(old_rr, cp, i); /* i değeri 251'e kadar çıkabilir; old_rr yalnızca 40 bayttır */
j ve i değişkenleri hiçbir zaman MAX_IPOPTLEN (40) değerine veya IP başlığında kalan gerçek bayt sayısına (hlen) karşı kontrol edilmemektedir. Uygulanan tek sınırlama (if (i > j) i = j;), i değerini yine saldırgan kontrollü olan j ile karşılaştırmaktadır; bu nedenle gerçek bir güvenlik payı sağlamaz.
Kök Neden (Adım Adım)
wait_packet()(waitpacket.c),read_packet()/pcap_recv()aracılığıyla ham bir paket alır.- Paketin hedef adresinin yerel arayüzle eşleştiğini ve (ICMP olmayan,
--rand-destkullanılmayan durumlarda) kaynak adresinin yapılandırılmış uzak hedefle eşleştiğini kontrol eder, ardındanrecv_tcp()/recv_udp()/recv_icmp()fonksiyonlarını çağırır. - Bu fonksiyonlar yalnızca portu (TCP/UDP için) veya ICMP id/type değerlerini (ICMP için) doğrular. TCP sequence/ack doğrulaması yapılmaz; bu nedenle yapılandırılmış hedeften geliyormuş gibi görünen paketler sahte (spoofed) olarak gönderilen bir saldırgan için "eşleşme" koşulunu sağlamak oldukça kolaydır.
- Paket "eşleşme" olarak değerlendirilirse ve hping
-G/--rrouteile çalıştırılmışsa,wait_packet()şu çağrıyı yapar:display_ipopt(ip_packet); display_ipopt(), sabit 20 baytlık IP başlığından hemen sonra IP seçeneklerini yürür.IPOPT_RR(değer 7) seçeneğiyle karşılaştığında, paketten sonraki iki ham baytıj(uzunluk) vei(işaretçi) olarak okur; herhangi bir sınır doğrulaması yapılmaz.iyalnızcajile (her ikisi de saldırgan kontrollü) sınırlandırılır, ardındanIPOPT_MINOFF(4) kadar azaltılır. Ulaşılabilecek maksimum değer: 255 − 4 = 251.memcpy(old_rr, cp, i)işlemi, 40 baytlık global tampona 251 bayta kadar veri yazar; bu da saldırganın paketinden doğrudan alınan içerikle yaklaşık 211 baytlık bellek dışı yazma anlamına gelir.
old_rr static olarak tanımlandığından (stack üzerindeki yerel bir değişken değil) .bss segmentinde bulunur. Taşma, bağlayıcının (linker) bu tamponun hemen ardına yerleştirdiği global/statik verileri bozar. Bu, bir stack/dönüş adresi üzerine yazma değil, BSS/global veri bozulması ilkelidir.
Tetiklenme Ön Koşulları
| Koşul | Gerekli mi? | Not |
|---|---|---|
hping'in -G / --rroute ile çalıştırılması |
Evet | Varsayılan davranış değildir |
| Alınan paketin "eşleşme" olarak sınıflandırılması | Evet | Doğru hedef IP (operatörün makinesi); ICMP dışı trafik için ayrıca doğru kaynak IP (yapılandırılmış hedef) ve eşleşen port gerekir |
| Saldırganın konumu | Yol üzerinde (on-path), sorgulanan hedefin kendisi veya yol dışı kör sahtecilik (off-path blind spoofing) yapan saldırgan | recv_tcp()/recv_udp()/recv_icmp() TCP sequence/ack veya kriptografik doğrulama yapmaz; yapılandırılmış hedefin kaynak IP'sini sahteleyip port'u tahmin etmek/gözlemlemek UDP/ICMP modlarında yeterlidir, bu uygulamada TCP modu için de büyük ölçüde yeterlidir |
| Kötü amaçlı IP başlığı | Evet | IPOPT_MINOFF çıkarıldıktan sonra i > 40 olacak şekilde uzunluk/işaretçi baytları ayarlanmış bir IPOPT_RR seçeneği içermelidir |
Etki
- Doğrulandı:
hping -Gile çalışırken ağ üzerinden erişilebilen, process'in global belleğine (.bss) yaklaşık 211 bayta kadar, deterministik ve saldırgan kontrollü bellek dışı yazma. - Doğrulandı: hping process'i için güvenilir şekilde çökme / hizmet reddi (DoS).
- Doğrulanmadı (binary'ye bağlı): Bu açığın kontrol akışı ele geçirmeye veya rastgele kod çalıştırmaya yükseltilip yükseltilemeyeceği, bağlayıcının nihai binary'de
old_rryanına hangi veriyi yerleştirdiğine bağlıdır (derleyici, derleyici sürümü, bağlama sırası ve derleme bayrakları etkilidir). Bu raporda kanıtlanmamıştır ve gerçek binary üzerinde ayrı bir analiz yapılmadan (örn.nm/objdump -t) varsayılmamalıdır.
CVSS 4.0 Değerlendirmesi
Skor: 6.0 — MEDIUM
Vektör: CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N
| Metrik | Değer | Açıklama |
|---|---|---|
| AV (Attack Vector) | Network (N) | Saldırı ağ üzerinden gerçekleştirilebilir |
| AC (Attack Complexity) | High (H) | Paketin "eşleşme" olarak kabul edilmesi için doğru kaynak/hedef IP ve port bilgisinin sağlanması gerekir |
| AT (Attack Requirements) | Present (P) | hping'in -G / --rroute ile ve aktif bir probe sırasında çalışıyor olması gerekir |
| PR (Privileges Required) | None (N) | Saldırganın ayrıcalığa ihtiyacı yoktur |
| UI (User Interaction) | Passive (P) | Operatörün hping'i ilgili seçeneklerle çalıştırması gerekir |
| VC (Confidentiality) | None (N) | Gizlilik etkisi gösterilmemiştir |
| VI (Integrity) | Low (L) | Global (BSS) verilerde sınırlı bozulma |
| VA (Availability) | High (H) | Process çökmesi / hizmet reddi |
| SC / SI / SA | None (N) | Sonraki sistemler üzerinde etki yoktur |
Önerilen Düzeltme
memcpy öncesinde kopyalama uzunluğu hem sabit tampon boyutuna hem de IP başlığında kalan gerçek uzunluğa karşı sınırlandırılmalıdır:
case IPOPT_RR:
j = *++cp;
i = *++cp;
hlen -= 2;
if (i > j)
i = j;
i -= IPOPT_MINOFF;
if (i <= 0)
continue;
if (i > MAX_IPOPTLEN) /* eklenen sınır */
i = MAX_IPOPTLEN;
if (i > hlen) /* eklenen sınır: gerçek başlığın ötesini okuma */
i = hlen;
...
memcpy(old_rr, cp, i);
Aynı fonksiyondaki IPOPT_LSRR dalı da aynı sınıftan bir sorun taşımaktadır (saldırgan kontrollü j değerine göre cp işaretçisinin sınırsız ileri hareketi). Sabit boyutlu bir tampona yazmasa da aynı şekilde incelenmeli ve sınırlandırılmalıdır.
Yeniden Üretme Notları
Zafiyet, ağ üzerinde sahtecilik yapmadan, display_ipopt() fonksiyonunu doğrudan çağıran küçük bir test harness'ı ile yerel olarak yeniden üretilebilir. Harness, i > 40 olmasını sağlayacak uzunluk/işaretçi baytlarına sahip hatalı biçimlendirilmiş bir IPOPT_RR seçeneği içeren elle hazırlanmış bir tampon ile -fsanitize=address bayrağıyla derlenmelidir. ASan, memcpy satırında bir global-buffer-overflow raporlayacaktır.
Ortam
- İncelenen kaynak:
hping-master(hping2 kod tabanı, dosyalar 1999–2004 tarihli, antirez'e ait$Id$etiketleri) - Doğrulama yöntemi: Statik kaynak kod incelemesi ile doğrulanmıştır; dinamik doğrulama (ASan harness çalıştırması) beklemededir. İnceleme ortamında
libpcap-deveksikliği nedeniyle engellenmiştir; bu durum zafiyete özgü değildir.
Açıklama (Disclosure)
Zafiyet, standart koordineli ifşa pratiğine uygun olarak, kamuya açık CVE ataması öncesinde upstream'e bildirilmiştir.
English Version
Summary
display_ipopt() in display_ipopt.c (hping2 codebase) copies attacker-controlled data into a fixed-size 40-byte global buffer (old_rr[MAX_IPOPTLEN]) using a length value taken directly from an unvalidated byte in the received IP packet. The copy length is bounded only by 0xFF, not by MAX_IPOPTLEN or by the actual remaining IP header length. This allows an out-of-bounds write of up to ~211 bytes past the buffer, with both length and content fully controlled by whoever sent the packet.
Vulnerability Details
| Field | Value |
|---|---|
| CVE | CVE-2026-136131 |
| CWE | CWE-787 (Out-of-bounds Write), related to CWE-20 (Improper Input Validation) |
| Component | display_ipopt.c, function display_ipopt() |
| Trigger path | wait_packet() → display_ipopt() in waitpacket.c |
| CVSS Version | 4.0 |
| CVSS Score | 6.0 (MEDIUM) |
| CVSS Vector | CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N |
Affected Code
display_ipopt.c:
static int old_rrlen;
static char old_rr[MAX_IPOPTLEN]; // MAX_IPOPTLEN == 40 (hping2.h)
...
case IPOPT_RR:
j = *++cp; /* option length byte — raw, attacker-controlled (0–255) */
i = *++cp; /* option pointer byte — raw, attacker-controlled (0–255) */
hlen -= 2;
if (i > j)
i = j;
i -= IPOPT_MINOFF; /* IPOPT_MINOFF == 4 */
if (i <= 0)
continue;
...
old_rrlen = i;
memcpy(old_rr, cp, i); /* i can be up to 251; old_rr is only 40 bytes */
Neither j nor i is ever checked against MAX_IPOPTLEN (40) or against the actual bytes remaining in the IP header (hlen). The only clamp applied (if (i > j) i = j;) bounds i against j, which is itself an attacker-controlled byte, so it provides no real safety margin.
Root Cause, Step by Step
wait_packet()inwaitpacket.creceives a raw packet viaread_packet()/pcap_recv().- It checks that the packet's destination matches the local interface and (for non-ICMP, non-
--rand-destcases) that the source matches the configured remote target, then callsrecv_tcp()/recv_udp()/recv_icmp(). - These functions validate only the port (for TCP/UDP) or ICMP id/type (for ICMP). No TCP sequence/ack validation is performed, so a match is trivially achievable by an attacker who can spoof packets appearing to originate from the configured target.
- If the packet is deemed a "match" and hping was invoked with
-G/--rroute,wait_packet()calls:display_ipopt(ip_packet); display_ipopt()walks the IP options starting right after the fixed 20-byte IP header. When it encounters option typeIPOPT_RR(value 7), it reads the next two raw bytes from the packet asj(length) andi(pointer), with no bounds validation.iis clamped only againstj(both attacker-controlled), then reduced byIPOPT_MINOFF(4). Maximum achievable value: 255 − 4 = 251.memcpy(old_rr, cp, i)writes up to 251 bytes into a 40-byte global buffer, i.e. up to ~211 bytes of out-of-bounds write, with content taken directly from attacker-supplied packet bytes.
Because old_rr is declared static (not a stack local), it resides in the .bss segment. The overflow corrupts whatever global/static data the linker placed immediately after it. This is not a stack/return-address overwrite, but a BSS/global-data corruption primitive.
Preconditions to Trigger
| Condition | Required? | Notes |
|---|---|---|
hping run with -G / --rroute |
Yes | Not default behavior |
| Received packet classified as "match" | Yes | Requires correct destination IP (= operator's host), and for non-ICMP traffic correct source IP (= configured target) and matching port |
| Attacker position | On-path, OR the probed target itself, OR an off-path blind spoofer | No TCP sequence/ack or cryptographic validation is performed by recv_tcp()/recv_udp()/recv_icmp(), so blind spoofing of the configured target's source IP plus a guessed/observed source port is sufficient for UDP/ICMP modes and largely sufficient for TCP mode as implemented here |
| Malicious IP header | Yes | Must contain an IPOPT_RR option with length/pointer bytes set to trigger i > 40 after the IPOPT_MINOFF subtraction |
Impact
- Confirmed: Deterministic, attacker-controlled out-of-bounds write of up to ~211 bytes into process global memory (
.bss), fully reachable over the network while hping is running with-G. - Confirmed: Reliable crash / denial of service against the hping process.
- Unconfirmed (binary-dependent): Whether this can be escalated to control-flow hijack or arbitrary code execution depends on what data the linker places adjacent to
old_rrin the final binary (compiler, compiler version, link order, and build flags all affect this). This has not been proven in this report and should not be assumed without separate binary-specific analysis (e.g.,nm/objdump -ton the actual shipped binary).
CVSS 4.0 Assessment
Score: 6.0 — MEDIUM
Vector: CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:P/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N
| Metric | Value | Rationale |
|---|---|---|
| AV (Attack Vector) | Network (N) | The attack can be delivered over the network |
| AC (Attack Complexity) | High (H) | The packet must be accepted as a "match", which requires correct source/destination IP and port information |
| AT (Attack Requirements) | Present (P) | hping must be running with -G / --rroute during an active probe |
| PR (Privileges Required) | None (N) | The attacker needs no privileges |
| UI (User Interaction) | Passive (P) | The operator must run hping with the relevant option |
| VC (Confidentiality) | None (N) | No confidentiality impact demonstrated |
| VI (Integrity) | Low (L) | Limited corruption of global (BSS) data |
| VA (Availability) | High (H) | Process crash / denial of service |
| SC / SI / SA | None (N) | No impact on subsequent systems |
Suggested Fix
Clamp the copy length against both the fixed buffer size and the actual remaining header length before the memcpy:
case IPOPT_RR:
j = *++cp;
i = *++cp;
hlen -= 2;
if (i > j)
i = j;
i -= IPOPT_MINOFF;
if (i <= 0)
continue;
if (i > MAX_IPOPTLEN) /* added bound */
i = MAX_IPOPTLEN;
if (i > hlen) /* added bound: don't read past actual header */
i = hlen;
...
memcpy(old_rr, cp, i);
The IPOPT_LSRR branch in the same function has the same class of issue (unbounded forward traversal of cp based on attacker-controlled j) and should be reviewed and bounded the same way, even though it does not write into a fixed buffer.
Reproduction Notes
This can be reproduced locally without network spoofing by linking a small harness that calls display_ipopt() directly with a hand-crafted buffer containing a malformed IPOPT_RR option (length/pointer bytes set to force i > 40), compiled with -fsanitize=address. ASan will report a global-buffer-overflow on the memcpy line.
Environment
- Source analyzed:
hping-master(hping2 codebase, files dated 1999–2004,$Id$tags from antirez) - Verification method: Confirmed via static source review; dynamic confirmation (ASan harness run) is pending, blocked in the review environment by missing
libpcap-dev, not by anything specific to the bug.
Disclosure
Reported upstream prior to public CVE assignment, per standard coordinated disclosure practice.
Referanslar / References
Araştırmacı: Umut SEVİNÇ (VulnSVNC)