Skip to content
Memory corruption Write-up Advanced

Yet another bug into Netfilter

Two bugs in the Linux kernel netfilter code: an integer overflow in a length check and a missing bounds check on an array index. Together they allowed an unprivileged local user to leak up to 28 bytes of kernel stack memory, including a stack canary and a data section address.

Arthur Mongodin Follow

Published on randorisec.fr

This year, I have done my end-of-study internship at Randorisec, the original purpose of my internship was to study different ways of doing variant analysis on open-sources project but also on closed-source software solutions. The Linux kernel is an attractive target, and so it was chosen as the target of my project.

Arthur Mongodin, on randorisec.fr

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

Context

Netfilter is the open-source packet filtering project that provides the Linux firewall. Its core logic lives in the kernel under /net/netfilter, and userland tools talk to it over netlink messages. The classic userland tool is iptables; in 2014 a new subsystem called nftable was added and is now configured through the nftables userland application.

Schema of the netfilter organization
Schema of the netfilter organization From the original on randorisec.fr

The central object is the table, which holds all the information about a filter. A table can contain objects such as sets, which store data. The following nftables command creates a table named my-table usable as a filter on the IP protocol:

Text
nft> add table ip my-table

The next command creates a set named my-set associated with my-table that stores IPv4 addresses:

Text
nft> add set ip my-table my-set {type: ipv4_addr;}

Chains of rules applied to received packets can then be created on top of these objects.

This article covers two bugs found in the netfilter kernel code during an end-of-study internship at Randorisec, whose original purpose was to study variant analysis on open-source and closed-source software. The Linux kernel was chosen as the target. The starting point was a survey of publicly disclosed bugs that could lead to interesting variant patterns; several bugs had been found and fixed in netfilter since the beginning of the year, such as CVE-2022-1015. One of the two bugs described here leads to information leakage and potentially to a fully functional local privilege escalation (LPE) exploit.

Setup

No special accounts or roles are involved. The relevant precondition is kernel configuration: the vulnerable code path is reachable when the kernel is compiled with CONFIG_USER_NS enabled. The netfilter netlink handler requires the CAP_NET_ADMIN capability, which an unprivileged user can acquire through user namespaces. The tooling used for the analysis was CodeQL, used to write a query for CVE-2022-1015 variants.

Finding it

In April 2022 David Bouman published an article about vulnerabilities in the Linux kernel. The researcher focused on CVE-2022-1015, the target of the variant analysis. That vulnerability is interesting because some out-of-bound bugs happen when user input checks are not well implemented, and this kind of bug can be found both in the Linux kernel and in userland applications. The bug is an integer overflow in nft_validate_register_load (/net/netfilter/nf_tables_api.c) at (0):

C
static int nft_validate_register_load(enum nft_registers reg, unsigned int len)
{
    if (reg < NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE)
        return -EINVAL;

    if (len == 0)
        return -EINVAL;

    if (reg * NFT_REG32_SIZE + len > sizeof_field(struct nft_regs, data))           <===== (0)
        return -ERANGE;

    return 0;
}

After understanding how this vulnerability works, the researcher wrote a CodeQL query able to find such a vulnerability. Analysing the query results produced several candidates for a CVE-2022-1015 variant.

The variant

One candidate stood out, located in nft_set_desc_concat_parse (/net/netfilter/nf_tables_api.c):

C
static int nft_set_desc_concat_parse(const struct nlattr *attr,
                     struct nft_set_desc *desc)
{
    struct nlattr *tb[NFTA_SET_FIELD_MAX + 1];
    u32 len;
    int err;

    err = nla_parse_nested_deprecated(tb, NFTA_SET_FIELD_MAX, attr,
                      nft_concat_policy, NULL);
    if (err < 0)
        return err;

    if (!tb[NFTA_SET_FIELD_LEN])
        return -EINVAL;

    len = ntohl(nla_get_be32(tb[NFTA_SET_FIELD_LEN]));

    if (len * BITS_PER_BYTE / 32 > NFT_REG32_COUNT)             <===== (1)
        return -E2BIG;

    desc->field_len[desc->field_count++] = len;                 <===== (2)

    return 0;
}

At (1) the pattern that matched the query appears. The left side of the comparison is len * BITS_PER_BYTE / 32. len is a 32-bit integer extracted from a netlink message with nla_get_be32, so it is user controllable. The macro BITS_PER_BYTE is defined in /include/linux/bits.h:

C
#define BITS_PER_BYTE       8

The multiplication len * BITS_PER_BYTE results in a left shift of three bits. The next operation, division by 32, results in a right shift of five bits. Five bits of len are therefore ignored: the three most significant and the two least significant.

The right side, NFT_REG32_COUNT, is defined in /include/uapi/linux/netfilter/nf_tables.h:

C
enum nft_registers {

    ...

    NFT_REG32_00    = 8,
    NFT_REG32_01,
    NFT_REG32_02,
    NFT_REG32_03,
    NFT_REG32_04,
    NFT_REG32_05,
    NFT_REG32_06,
    NFT_REG32_07,
    NFT_REG32_08,
    NFT_REG32_09,
    NFT_REG32_10,
    NFT_REG32_11,
    NFT_REG32_12,
    NFT_REG32_13,
    NFT_REG32_14,
    NFT_REG32_15,
};
...
#define NFT_REG32_COUNT (NFT_REG32_15 - NFT_REG32_00 + 1)

NFT_REG32_COUNT equals 23 - 8 + 1 = 16. Inverting the condition at (1) gives len < 64, but because five bits are ignored, those bits can be used to store an unwanted value at (2).

Unprivileged access

The kernel netfilter module is accessed through a netlink defined in /net/netfilter/nfnetlink.c:

C
static int __net_init nfnetlink_net_init(struct net *net)
{
    struct nfnl_net *nfnlnet = nfnl_pernet(net);
    struct netlink_kernel_cfg cfg = {
        .groups = NFNLGRP_MAX,
        .input  = nfnetlink_rcv,    <===== (3)
#ifdef CONFIG_MODULES
        .bind   = nfnetlink_bind,
#endif
    };

    nfnlnet->nfnl = netlink_kernel_create(net, NETLINK_NETFILTER, &cfg);
    if (!nfnlnet->nfnl)
        return -ENOMEM;
    return 0;
}

The input field at (3) is the function called when a message is received over the netfilter netlink:

C
static void nfnetlink_rcv(struct sk_buff *skb)
{
    struct nlmsghdr *nlh = nlmsg_hdr(skb);

    if (skb->len < NLMSG_HDRLEN ||
        nlh->nlmsg_len < NLMSG_HDRLEN ||
        skb->len < nlh->nlmsg_len)
        return;

    if (!netlink_net_capable(skb, CAP_NET_ADMIN)) {                         <===== (4)
        netlink_ack(skb, nlh, -EPERM, NULL);
        return;
    }

    if (nlh->nlmsg_type == NFNL_MSG_BATCH_BEGIN)
        nfnetlink_rcv_skb_batch(skb, nlh);
    else
        netlink_rcv_skb(skb, nfnetlink_rcv_msg);
}

At (4) there is a capability check through netlink_net_capable: the user must hold CAP_NET_ADMIN to use netfilter. That capability can be acquired with user namespaces (CONFIG_USER_NS). User namespaces have been a game changer in Linux kernel exploitation over the past few years, opening a new set of attack surfaces; they are also used to sandbox applications, which makes them a double-edged sword.

The call path from nfnetlink_rcv to nft_set_desc_concat_parse is:

Text
nfnetlink_rcv
    nfnetlink_rcv_skb_batch
        nfnetlink_rcv_batch
            nf_tables_newset
                nf_tables_set_desc_parse
                    nft_set_desc_concat
                        nft_set_desc_concat_parse

The intermediate functions hold no relevant information for the moment. With CONFIG_USER_NS enabled, the vulnerable code path is reachable.

Integer overflow verification into GDB
Integer overflow verification into GDB From the original on randorisec.fr

Why the integer overflow alone is weak

The bug seemed to have no impact on Linux security. The assignment at (2) hides a cast from a 32-bit unsigned integer to an 8-bit one, because the field_len field of nft_set_desc is of type u8:

C
struct nft_set_desc {
    unsigned int        klen;
    unsigned int        dlen;
    unsigned int        size;
    u8          field_len[NFT_REG32_COUNT];
    u8          field_count;
    bool            expr;
};

This greatly reduces the power of the overflow, since the two least significant bits cannot be used.

Exploitation

Step 1: notice the missing index check

While looking at how to exploit the previous bug, something stood out: there is no check on the index field_count before the assignment at (2). The parent function of nft_set_desc_concat_parse is nft_set_desc_concat (/net/netfilter/nf_tables_api.c):

C
static int nft_set_desc_concat(struct nft_set_desc *desc,
                   const struct nlattr *nla)
{
    struct nlattr *attr;
    int rem, err;

    nla_for_each_nested(attr, nla, rem) {                                   <===== (5)
        if (nla_type(attr) != NFTA_LIST_ELEM)
            return -EINVAL;

        err = nft_set_desc_concat_parse(attr, desc);                        <===== (6)
        if (err < 0)
            return err;
    }

    return 0;
}

The call at (6) sits inside the loop that starts at (5), and the loop body never verifies the value of desc->field_count. nla_for_each_nested iterates over all the netlink attributes supplied by the user, so supplying more than NFT_REG32_COUNT of them produces a buffer overflow.

Step 2: understand what gets overwritten

The first byte overflown is the field_count field, which stores the number of elements held in field_len. That field is the lever for the leak.

The target object is the netfilter set, represented by struct nft_set (/include/net/netfilter/nf_tables.h):

C
struct nft_set {
    struct list_head        list;
    struct list_head        bindings;
    struct nft_table        *table;
    possible_net_t          net;
    char                *name;
    u64             handle;
    u32             ktype;
    u32             dtype;
    u32             objtype;
    u32             size;
    u8              field_len[NFT_REG32_COUNT];
    u8              field_count;
    u32             use;
    atomic_t            nelems;
    u32             ndeact;
    u64             timeout;
    u32             gc_int;
    u16             policy;
    u16             udlen;
    unsigned char           *udata;
    /* runtime data below here */
    const struct nft_set_ops    *ops ____cacheline_aligned;
    u16             flags:14,
                    genmask:2;
    u8              klen;
    u8              dlen;
    u8              num_exprs;
    struct nft_expr         *exprs[NFT_SET_EXPR_MAX];
    struct list_head        catchall_list;
    unsigned char           data[]
        __attribute__((aligned(__alignof__(u64))));
};

Sets are allocated in nf_tables_newset (/net/netfilter/nf_tables_api.c), a parent of the vulnerable function:

C
static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info,
                const struct nlattr * const nla[])
{
    const struct nft_set_ops *ops;
    struct nft_set_desc desc;
    struct nft_set *set;
    size_t alloc_size;
    u64 size;
    ...

    memset(&desc, 0, sizeof(desc));             <===== (7)

    ...

    if (nla[NFTA_SET_DESC] != NULL) {
        err = nf_tables_set_desc_parse(&desc, nla[NFTA_SET_DESC]);              <===== (8)
        if (err < 0)
            return err;
    }

    ...

    size = 0;
    if (ops->privsize != NULL)
        size = ops->privsize(nla, &desc);
    alloc_size = sizeof(*set) + size + udlen;
    if (alloc_size < size || alloc_size > INT_MAX)
        return -ENOMEM;
    set = kvzalloc(alloc_size, GFP_KERNEL);                                     <===== (9)
    if (!set)
        return -ENOMEM;

    ...

    set->field_count = desc.field_count;
    for (i = 0; i < desc.field_count; i++)                                      <===== (10)
        set->field_len[i] = desc.field_len[i];

    ...

}

The call at (8) leads to the vulnerable function. Its first argument is the address of the local variable desc, initialised at (7). That is the object modified by nft_set_desc_concat_parse. Its field_count and field_len fields are used at (10) and stored into the freshly allocated nft_set from (9). If the out-of-bound has been used to override solely the field_len field of desc with a value bigger than 20 (end of the structure plus alignment), some stack data is copied into the nft_set structure at (10). This also produces an out-of-bound inside nft_set, but that is not useful for the leak.

Step 3: send the data back to userland

The information is returned through nf_tables_getset (/net/netfilter/nf_tables_api.c), reachable in a similar way to nf_tables_newset, which retrieves information about a registered set:

C
tatic int nf_tables_getset(struct sk_buff *skb, const struct nfnl_info *info,
                const struct nlattr * const nla[])
{
    const struct nft_set *set;
    struct sk_buff *skb2;
    struct nft_ctx ctx;
    int err;

    ...

    skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
    if (skb2 == NULL)
        return -ENOMEM;

    err = nf_tables_fill_set(skb2, &ctx, set, NFT_MSG_NEWSET, 0);           <===== (11)
    if (err < 0)
        goto err_fill_set_info;

    return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);            <===== (12)

}

Data is sent to userland over the netfilter netlink through nfnetlink_unicast at (12), and it is set up in the call to nf_tables_fill_set (/net/netfilter/nf_tables_api.c):

C
static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
                  const struct nft_set *set, u16 event, u16 flags)
{
    struct nlmsghdr *nlh;
    u32 portid = ctx->portid;
    struct nlattr *nest;
    u32 seq = ctx->seq;
    int i;

    event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event);
    nlh = nfnl_msg_put(skb, portid, seq, event, flags, ctx->family,
               NFNETLINK_V0, nft_base_seq(ctx->net));

    ...

    if (set->udata &&
        nla_put(skb, NFTA_SET_USERDATA, set->udlen, set->udata))
        goto nla_put_failure;

    ...

    if (set->field_count > 1 &&
        nf_tables_fill_set_concat(skb, set))                <===== (13)
        goto nla_put_failure;

    ...

    nlmsg_end(skb, nlh);
    return 0;

nla_put_failure:
    nlmsg_trim(skb, nlh);
    return -1;
}

At (13) another auxiliary function handles the field_len and field_count fields of nft_set:

C
static int nf_tables_fill_set_concat(struct sk_buff *skb,
                     const struct nft_set *set)
{
    struct nlattr *concat, *field;
    int i;

    concat = nla_nest_start_noflag(skb, NFTA_SET_DESC_CONCAT);
    if (!concat)
        return -ENOMEM;

    for (i = 0; i < set->field_count; i++) {                <===== (14)
        field = nla_nest_start_noflag(skb, NFTA_LIST_ELEM);
        if (!field)
            return -ENOMEM;

        if (nla_put_be32(skb, NFTA_SET_FIELD_LEN,           <===== (15)
                 htonl(set->field_len[i])))
            return -ENOMEM;

        nla_nest_end(skb, field);
    }

    nla_nest_end(skb, concat);

    return 0;
}

At (14) the loop runs set->field_count times, and at each iteration one element of the set->field_len buffer is added to the socket buffer at (15). So if the off-by-one has been produced at (2), stack information is copied into the heap at (10) and the user can read it through sockets.

A leak example
A leak example From the original on randorisec.fr

The leak is the result of the proof of concept. In these specific circumstances it leaks a stack canary and an address of the data section.

Limitations

The leak is not very powerful: it is restricted to 28 bytes because of the organisation of the nft_set structure. A bigger leak would require overwriting the least significant bytes of the udata field, which can lead to a segmentation fault in nf_tables_fill_set. The leak also depends on the stack organisation, which depends on the compilation, so it can provide interesting information on a specific kernel and be useless on the next version.

Root cause

Two mistakes combine. First, the length check at (1) in nft_set_desc_concat_parse is an integer overflow: len * BITS_PER_BYTE / 32 discards five bits of the user-controlled 32-bit len, so the comparison does not constrain the value that is later stored. Second, and more importantly for the leak, nft_set_desc_concat iterates over user-supplied nested attributes at (5) and calls nft_set_desc_concat_parse at (6) without ever checking desc->field_count against the size of field_len, so more than NFT_REG32_COUNT attributes overflow the array and the adjacent field_count byte. The capability check at (4) does not stop an unprivileged attacker because CAP_NET_ADMIN can be obtained inside a user namespace when CONFIG_USER_NS is enabled.

Impact

An unprivileged local user can reach the vulnerable path and obtain a 28-byte kernel infoleak containing, in the tested circumstances, a stack canary and a data section address. The researcher did not manage to turn the out-of-bound into a fully functional LPE exploit before public disclosure, and the write primitive is weak. The leak's usefulness depends on the kernel build and stack layout.

Fix

The bug was fixed on 31 May 2022 by commit [redacted]. That commit fixes both the integer overflow and the out-of-bound. The patch of the integer overflow allows a length up to 255, which would have made exploitation of the vulnerability easier. The vulnerability was officially disclosed on oss-security and assigned CVE-2022-1972.

Variants to test

  1. Grep for arithmetic length checks of the form x * CONST / CONST > LIMIT in netlink attribute parsers. A positive result is a check where the multiplication and division cancel bits of a user-controlled value, letting a value outside the intended range through.
  2. Look for loops over nested netlink attributes (nla_for_each_nested) that write into a fixed-size array indexed by a counter stored in the same structure, with no bound check on the counter. A positive result is a counter that can exceed the array size and overwrite the adjacent field.
  3. Trace parsers that fill a stack struct and then copy its fields into a heap object, as nf_tables_newset does at (10). A positive result is a path where an overflown stack field causes stack bytes to be copied into a heap object that is later returned to userland.
  4. Check whether the corresponding getter (such as nf_tables_fill_set and nf_tables_fill_set_concat) serialises the overflown field back to userland. A positive result is a getter that iterates the corrupted counter and emits the adjacent bytes in a netlink reply.
  5. Review the hypothetical LPE directions: overwriting udlen to obtain a heap infoleak, and overwriting num_exprs beyond NFT_SET_EXPR_MAX so that part of data is treated as exprs, then triggering nft_expr_destroy through an error in expression management. These were untested hypotheses; a positive result would be a controlled free or use-after-free reachable from the same overflow.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 28 min read.

What happened, in plain words

A security researcher spent an internship looking for bugs in the Linux kernel, the core program that sits between your applications and the computer's hardware. The plan was to take bugs that had already been found and published, and look for similar mistakes elsewhere in the same code. This technique is called variant analysis: if a developer made one mistake in one place, the same mistake often exists in a neighbouring place.

The area under the microscope was netfilter, the part of Linux that acts as a firewall. A firewall is the gatekeeper that decides which network traffic is allowed in and out of a machine. Two bugs were found. One of them lets a normal user on a machine read a small amount of memory that they should not be able to see. That kind of bug is called an information leak, or infoleak. One of them leads to an information leak, and potentially to a full local privilege escalation, usually shortened to LPE: a way for an ordinary user to become the all-powerful administrator (root) on the same machine. That second step was not completed before the bug was fixed and published.

This article walks through how the bugs were found, how the leak works, and why the researcher thinks a full takeover might be possible.

A short introduction to netfilter

Netfilter is an open-source project that performs packet filtering, which is the job people usually call "the Linux firewall". A packet is a small chunk of data travelling over a network, like one envelope in a very long postal exchange. Filtering means deciding, envelope by envelope, whether to let it through, drop it, or do something else with it.

The project is often mentioned together with iptables, which is the userland application used to configure the firewall. "Userland" means the ordinary programs you run, as opposed to the kernel, which is the privileged core of the operating system. In 2014 a new subsystem was added to netfilter, called nftable, and it is now configured through the nftables userland application. Think of iptables and nftables as two different remote controls for the same television: the television is the kernel code, the remotes are the programs you type commands into.

Schema of the netfilter organization
Schema of the netfilter organization From the original on randorisec.fr

The diagram shows how the pieces fit together: the userland tools on one side, the kernel-side netfilter code on the other, and the messages that travel between them.

The core logic of netfilter is implemented inside the kernel, in the directory /net/netfilter. The userland tools talk to it by sending netlink messages. Netlink is a communication channel built into Linux that lets ordinary programs exchange structured messages with the kernel. It is a bit like a service counter: you fill in a form (the message), hand it over, and the kernel reads it and acts on it.

A very basic usage

The main object in netfilter is the table. A table holds all the information about one filter. The following nftables command creates a new table named my-table, which can be used as a filter on the IP protocol (IP is the protocol that carries most internet traffic):

Text
nft> add table ip my-table

Line by line: nft> is the prompt of the nftables command tool, the place where you type. add table says you want to create a new table. ip says the table applies to IPv4 traffic. my-table is the name you choose for it, so you can refer to it later.

A table can contain different objects, such as sets, which are used to store data. The following command creates a new set associated with the table my-table, named my-set, that stores IPv4 addresses:

Text
nft> add set ip my-table my-set {type: ipv4_addr;}

Line by line: add set asks for a new set. ip my-table says which table it belongs to. my-set is the name of the new set. The part in braces, {type: ipv4_addr;}, declares what kind of values the set will hold: IPv4 addresses, such as the numbers that identify machines on a network. A set is like a guest list at a door: it stores a collection of entries that rules can check against.

Finally, you can create chains of rules that get applied to received packets. A chain is an ordered list of checks, like a checklist a guard follows for every visitor.

Starting point

In April 2022, David Bouman published an article about vulnerabilities in the Linux kernel. A vulnerability is a flaw in software that can be abused to make it behave in a way its authors did not intend. The researcher focused on one of them, CVE-2022-1015. CVE stands for Common Vulnerabilities and Exposures: it is a public catalogue where each known vulnerability gets a unique identifier, so people can refer to the same bug unambiguously.

That vulnerability is interesting because some out-of-bound bugs happen when checks on user input are not well implemented. An out-of-bound bug is one where a program reads or writes memory outside the area it was supposed to touch, like writing past the edge of a page in a notebook and marking the next page by accident. This kind of bug can be found both in the Linux kernel and in ordinary userland applications.

The bug is an integer overflow in the function nft_validate_register_load, in the file /net/netfilter/nf_tables_api.c, at the line marked (0):

C
static int nft_validate_register_load(enum nft_registers reg, unsigned int len)
{
    if (reg < NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE)
        return -EINVAL;

    if (len == 0)
        return -EINVAL;

    if (reg * NFT_REG32_SIZE + len > sizeof_field(struct nft_regs, data))           <===== (0)
        return -ERANGE;

    return 0;
}

Line by line: the function is called nft_validate_register_load and takes two inputs, reg and len. The first if rejects a reg value that is too small, returning an error code -EINVAL (invalid argument). The second if rejects a length of zero. The third if, marked (0), is the important one: it computes reg * NFT_REG32_SIZE + len and compares it with the size of a data field. If the sum is larger than that size, it returns -ERANGE (out of range). An integer overflow means the arithmetic wraps around: if the numbers are large enough, the sum can become small again, so the check passes even though the real value is far too big. It is like a car odometer that rolls back to zero after the maximum number: the display says "small" while the car has actually travelled a huge distance.

After reading and understanding how this vulnerability works, the researcher wrote a CodeQL query able to find such a vulnerability. CodeQL is a tool that treats source code as a database you can ask questions of, so you can search for patterns across a whole codebase instead of reading it by hand. The query is the question; the results are the places that match. Analysing the different results of the query produced several candidates for a CVE-2022-1015 variant, meaning other places in the code with a similar shape.

CVE-2022-1015 variant

The bug

One of these candidates caught the researcher's attention. It is located inside the function nft_set_desc_concat_parse, in /net/netfilter/nf_tables_api.c:

C
static int nft_set_desc_concat_parse(const struct nlattr *attr,
                     struct nft_set_desc *desc)
{
    struct nlattr *tb[NFTA_SET_FIELD_MAX + 1];
    u32 len;
    int err;

    err = nla_parse_nested_deprecated(tb, NFTA_SET_FIELD_MAX, attr,
                      nft_concat_policy, NULL);
    if (err < 0)
        return err;

    if (!tb[NFTA_SET_FIELD_LEN])
        return -EINVAL;

    len = ntohl(nla_get_be32(tb[NFTA_SET_FIELD_LEN]));

    if (len * BITS_PER_BYTE / 32 > NFT_REG32_COUNT)             <===== (1)
        return -E2BIG;

    desc->field_len[desc->field_count++] = len;                 <===== (2)

    return 0;
}

Line by line: the function receives a netlink attribute attr (one field of a message) and a pointer to a description structure desc. It declares a small array tb to hold parsed sub-fields, a 32-bit unsigned integer len, and an error variable err. It calls nla_parse_nested_deprecated, which unpacks the nested attributes inside attr into tb; if that fails, it returns the error. It then checks that the sub-field NFTA_SET_FIELD_LEN is present, returning -EINVAL if not. It reads that sub-field with nla_get_be32 (which reads a 32-bit big-endian number from the message) and converts it to host byte order with ntohl. Byte order is just the convention for which end of a number comes first in memory; ntohl translates from network order to the local machine's order. Then comes the check at (1): if len * BITS_PER_BYTE / 32 is greater than NFT_REG32_COUNT, it returns -E2BIG (too big). Finally, at (2), it stores len into the array desc->field_len at position desc->field_count, and increments field_count afterwards.

At (1) we see the pattern that matched the query. Let's focus on the left part of the comparison, len * BITS_PER_BYTE / 32. len is a 32-bit integer extracted from a netlink message with nla_get_be32, so we can assume it is user controllable: the attacker chooses it. The macro BITS_PER_BYTE is defined in /include/linux/bits.h:

C
#define BITS_PER_BYTE       8

Line by line: this is a macro, a name that the compiler replaces with a value wherever it appears. BITS_PER_BYTE stands for 8, the number of bits in a byte. A bit is a single binary digit, 0 or 1; a byte is eight of them.

The multiplication len * BITS_PER_BYTE results in a left shift of three bits. Multiplying by 8 is the same as moving every bit three places to the left, because 8 is 2 to the power of 3. The next arithmetic operation is the division by 32, which results in a right shift of five bits, because 32 is 2 to the power of 5. We understand that five bits of len are ignored: the three most significant and the two least significant. "Most significant" means the bits that carry the largest value, like the leading digits of a number; "least significant" means the trailing ones. Those five bits are dropped by the arithmetic, so they have no effect on the comparison.

Now let's look at the right side of the comparison. The macro NFT_REG32_COUNT is defined in the file /include/uapi/linux/netfilter/nf_tables.h:

C
enum nft_registers {

    ...

    NFT_REG32_00    = 8,
    NFT_REG32_01,
    NFT_REG32_02,
    NFT_REG32_03,
    NFT_REG32_04,
    NFT_REG32_05,
    NFT_REG32_06,
    NFT_REG32_07,
    NFT_REG32_08,
    NFT_REG32_09,
    NFT_REG32_10,
    NFT_REG32_11,
    NFT_REG32_12,
    NFT_REG32_13,
    NFT_REG32_14,
    NFT_REG32_15,
};
...
#define NFT_REG32_COUNT (NFT_REG32_15 - NFT_REG32_00 + 1)

Line by line: an enum is a list of named integer constants. NFT_REG32_00 is explicitly set to 8, and each following name takes the next value automatically, so NFT_REG32_01 is 9, and so on up to NFT_REG32_15, which is 23. The macro NFT_REG32_COUNT computes NFT_REG32_15 - NFT_REG32_00 + 1, which is the number of entries in that range.

We have NFT_REG32_COUNT equal to 23 - 8 + 1 = 16. If we invert the condition at (1) in order to get a condition on len, we get len < 64. Nevertheless, in this comparison five bits are ignored, so those five bits could be used to store an unwanted value at (2). In other words, the check thinks it is limiting the value, but some of the bits of the value never reach the comparison, so a carefully chosen number can pass the check while still being large.

The next step is to find a way for a random unprivileged user to reach this buggy code. "Unprivileged" means an ordinary account without special rights, like a normal user on a shared computer.

Unprivileged access

The kernel netfilter module can be accessed from a netlink defined in /net/netfilter/nfnetlink.c:

C
static int __net_init nfnetlink_net_init(struct net *net)
{
    struct nfnl_net *nfnlnet = nfnl_pernet(net);
    struct netlink_kernel_cfg cfg = {
        .groups = NFNLGRP_MAX,
        .input  = nfnetlink_rcv,    <===== (3)
#ifdef CONFIG_MODULES
        .bind   = nfnetlink_bind,
#endif
    };

    nfnlnet->nfnl = netlink_kernel_create(net, NETLINK_NETFILTER, &cfg);
    if (!nfnlnet->nfnl)
        return -ENOMEM;
    return 0;
}

Line by line: this function runs when a network namespace is initialised. A namespace is an isolated view of part of the system, so several namespaces can exist side by side without seeing each other. The function builds a configuration structure cfg for the netlink channel. The input field, marked (3), names the function that will be called whenever a message arrives on this channel: nfnetlink_rcv. The bind field is set only if the kernel was compiled with module support. Then netlink_kernel_create creates the channel for the NETLINK_NETFILTER protocol, and if that fails the function returns -ENOMEM (out of memory).

The input field of the structure netlink_kernel_cfg at (3) gives us the function that will be called when a message is received via the netfilter netlink. Let's look at this handler:

C
static void nfnetlink_rcv(struct sk_buff *skb)
{
    struct nlmsghdr *nlh = nlmsg_hdr(skb);

    if (skb->len < NLMSG_HDRLEN ||
        nlh->nlmsg_len < NLMSG_HDRLEN ||
        skb->len < nlh->nlmsg_len)
        return;

    if (!netlink_net_capable(skb, CAP_NET_ADMIN)) {                         <===== (4)
        netlink_ack(skb, nlh, -EPERM, NULL);
        return;
    }

    if (nlh->nlmsg_type == NFNL_MSG_BATCH_BEGIN)
        nfnetlink_rcv_skb_batch(skb, nlh);
    else
        netlink_rcv_skb(skb, nfnetlink_rcv_msg);
}

Line by line: the function receives a socket buffer skb, which is the container for a network message. It extracts the message header nlh. The first if performs sanity checks on lengths: the buffer must be at least as long as a header, the header must claim a length of at least a header, and the buffer must be at least as long as the header claims. If any of these fail, the function returns without doing anything, which prevents reading past the end of the message. Then comes the capability check at (4): netlink_net_capable asks whether the sender holds the CAP_NET_ADMIN capability. A capability is a specific permission bit in Linux; CAP_NET_ADMIN is the right to administer network settings. If the sender does not have it, the kernel sends back an error -EPERM (operation not permitted) and stops. If the sender does have it, the message is dispatched: batch messages go to nfnetlink_rcv_skb_batch, everything else to netlink_rcv_skb with the handler nfnetlink_rcv_msg.

We see a capability check at (4) done by the function netlink_net_capable: it is mandatory that the user has the CAP_NET_ADMIN capability to use netfilter. Luckily for us, this capability can be acquired with user namespaces (CONFIG_USER_NS). A user namespace is a feature that lets an ordinary user create an isolated environment in which they appear to be root, with a full set of capabilities, but only inside that environment. CONFIG_USER_NS is the kernel build option that enables this feature. User namespaces have been a game changer in Linux kernel exploitation over the past few years: they have opened a new set of attack surfaces. It is somewhat ironic, because they are also used to sandbox applications, which makes them a double-edged sword. A sandbox is a restricted box an application runs inside so that if it misbehaves it cannot harm the rest of the system.

Let's get back to our topic. We can map the call path from nfnetlink_rcv to nft_set_desc_concat_parse as follows:

Text
nfnetlink_rcv
    nfnetlink_rcv_skb_batch
        nfnetlink_rcv_batch
            nf_tables_newset
                nf_tables_set_desc_parse
                    nft_set_desc_concat
                        nft_set_desc_concat_parse

Line by line: each line is a function, and the indentation shows which function calls which. A message arrives at nfnetlink_rcv, which hands batch messages to nfnetlink_rcv_skb_batch, which calls nfnetlink_rcv_batch, which calls nf_tables_newset (the function that creates a new set), which calls nf_tables_set_desc_parse, which calls nft_set_desc_concat, which finally calls the vulnerable nft_set_desc_concat_parse. Reading a call path is like following a chain of people passing a note: each one hands it to the next until it reaches the person who acts on it.

There is no relevant information within the intermediate functions, so we are going to ignore them for the moment. If the kernel is compiled with CONFIG_USER_NS enabled, we will be able to reach our vulnerable code path.

Integer overflow verification into GDB
Integer overflow verification into GDB From the original on randorisec.fr

Well, what can we do?

Sadly, it seems that this bug did not have any impact on Linux security. Indeed, the assignment at (2) hides a cast from a 32-bit unsigned integer into an 8-bit one, because the field field_len of the nft_set_desc structure is of type u8:

C
struct nft_set_desc {
    unsigned int        klen;
    unsigned int        dlen;
    unsigned int        size;
    u8          field_len[NFT_REG32_COUNT];
    u8          field_count;
    bool            expr;
};

Line by line: this declares a structure, which is a bundle of named fields stored together in memory, like a form with several boxes. klen, dlen and size are unsigned int, typically 32 bits each. field_len is an array of NFT_REG32_COUNT elements, each of type u8, which is an unsigned integer of 8 bits, able to hold values from 0 to 255. field_count is also a u8, and expr is a boolean (true or false).

A cast is a conversion from one type to another. When a 32-bit value is stored into an 8-bit slot, only the lowest 8 bits survive; the rest are discarded. This greatly reduces the power of the overflow, since the two least significant bits cannot be used. In other words, the value that ends up in memory is not the full number the attacker chose, but a truncated version of it, which limits what can be done with it.

A strange neighbour

However, this is not the end of the adventure. When looking at how to exploit the previous bug, something halted the researcher: there was no check on the index field_count before the assignment at (2). An index is the position used to pick a slot in an array; if nothing checks that the position stays inside the array, the program can write past its end.

The parent function of nft_set_desc_concat_parse is nft_set_desc_concat, in /net/netfilter/nf_tables_api.c:

C
static int nft_set_desc_concat(struct nft_set_desc *desc,
                   const struct nlattr *nla)
{
    struct nlattr *attr;
    int rem, err;

    nla_for_each_nested(attr, nla, rem) {                                   <===== (5)
        if (nla_type(attr) != NFTA_LIST_ELEM)
            return -EINVAL;

        err = nft_set_desc_concat_parse(attr, desc);                        <===== (6)
        if (err < 0)
            return err;
    }

    return 0;
}

Line by line: the function takes a description desc and a netlink attribute nla. It declares attr to hold each sub-attribute, rem for the remaining length, and err for errors. The loop at (5), nla_for_each_nested, walks over every nested attribute inside nla, one at a time. For each one, it checks that the type is NFTA_LIST_ELEM, returning -EINVAL otherwise. Then at (6) it calls nft_set_desc_concat_parse on that attribute, and if that call returns an error, it propagates the error and stops. If everything succeeds, it returns 0.

The call to nft_set_desc_concat_parse is done at (6), but the most interesting thing is that the call is located in a loop that starts at (5), and there is no verification in the loop body on the value of desc->field_count. nla_for_each_nested will loop over all the netlink attributes provided by the user; if the user provides more than NFT_REG32_COUNT, a buffer overflow will happen. A buffer overflow is when a program writes more data into a fixed-size area than it can hold, so the extra data spills into whatever sits next to it in memory, like pouring too much water into a glass and soaking the table around it.

Gimme gimme gimme an infoleak

We will see how to turn this buffer overflow into a kernel infoleak. The first byte that will be overflown is the field field_count, which stores the number of elements stored in the field field_len. We will use this field to reach our goal.

Netfilter sets

We will use the netfilter sets, represented by the structure nft_set, in /include/net/netfilter/nf_tables.h:

C
struct nft_set {
    struct list_head        list;
    struct list_head        bindings;
    struct nft_table        *table;
    possible_net_t          net;
    char                *name;
    u64             handle;
    u32             ktype;
    u32             dtype;
    u32             objtype;
    u32             size;
    u8              field_len[NFT_REG32_COUNT];
    u8              field_count;
    u32             use;
    atomic_t            nelems;
    u32             ndeact;
    u64             timeout;
    u32             gc_int;
    u16             policy;
    u16             udlen;
    unsigned char           *udata;
    /* runtime data below here */
    const struct nft_set_ops    *ops ____cacheline_aligned;
    u16             flags:14,
                    genmask:2;
    u8              klen;
    u8              dlen;
    u8              num_exprs;
    struct nft_expr         *exprs[NFT_SET_EXPR_MAX];
    struct list_head        catchall_list;
    unsigned char           data[]
        __attribute__((aligned(__alignof__(u64))));
};

Line by line: this is the layout of a set in memory. list and bindings are list links, used to chain objects together. table points to the table the set belongs to. net records the network namespace. name points to the set's name. handle is a 64-bit identifier. ktype, dtype, objtype and size are 32-bit fields describing the set. Then comes field_len, an array of NFT_REG32_COUNT bytes, followed immediately by field_count, a single byte. Because they sit next to each other, writing past the end of field_len lands on field_count. Further down are use, nelems, ndeact, timeout, gc_int, policy, udlen and udata. udata is a pointer to user data, and udlen is its length. Then come ops, a pointer to the set's operations; flags and genmask, packed into 16 bits; klen, dlen and num_exprs, single bytes; exprs, an array of pointers to expressions; catchall_list; and finally data, a flexible array at the end whose size is decided at allocation time. A pointer is a value that holds the memory address of something else, like a house number that tells you where to find a building.

These sets are allocated in the function nf_tables_newset, in /net/netfilter/nf_tables_api.c, which is a parent of the vulnerable function nft_set_desc_concat_parse:

C
static int nf_tables_newset(struct sk_buff *skb, const struct nfnl_info *info,
                const struct nlattr * const nla[])
{
    const struct nft_set_ops *ops;
    struct nft_set_desc desc;
    struct nft_set *set;
    size_t alloc_size;
    u64 size;
    ...

    memset(&desc, 0, sizeof(desc));             <===== (7)

    ...

    if (nla[NFTA_SET_DESC] != NULL) {
        err = nf_tables_set_desc_parse(&desc, nla[NFTA_SET_DESC]);              <===== (8)
        if (err < 0)
            return err;
    }

    ...

    size = 0;
    if (ops->privsize != NULL)
        size = ops->privsize(nla, &desc);
    alloc_size = sizeof(*set) + size + udlen;
    if (alloc_size < size || alloc_size > INT_MAX)
        return -ENOMEM;
    set = kvzalloc(alloc_size, GFP_KERNEL);                                     <===== (9)
    if (!set)
        return -ENOMEM;

    ...

    set->field_count = desc.field_count;
    for (i = 0; i < desc.field_count; i++)                                      <===== (10)
        set->field_len[i] = desc.field_len[i];

    ...

}

Line by line: the function receives the message buffer, some info, and the parsed attributes nla. It declares ops for the set operations, a local desc structure, a pointer set for the new set, and size variables. At (7), memset zeroes the whole desc structure, so every field starts at 0. At (8), if the message contains a NFTA_SET_DESC attribute, it calls nf_tables_set_desc_parse on it, passing the address of desc; this is the call that eventually reaches the vulnerable function. If that fails, it returns the error. It then computes how much memory the set needs: the size of the structure itself, plus any private size reported by ops, plus the length of user data. It checks that the total did not wrap around and is not absurdly large, returning -ENOMEM if so. At (9), kvzalloc allocates that memory, zeroed. At (10), it copies desc.field_count into the new set, then loops that many times copying each byte of desc.field_len into set->field_len.

We retrieve at (8) the call that leads to the vulnerable function. Its first argument is the address of the local variable desc, initialised at (7). This is the object that will be modified inside nft_set_desc_concat_parse. We can see that its fields field_count and field_len are used at (10) and stored into the freshly allocated nft_set from (9). So if the out-of-bound has been used to override solely the field field_len of desc with a value bigger than 20 (end of the structure plus alignment), some data from the stack will be copied into the nft_set structure at (10). The stack is the region of memory where a program keeps its local variables and the bookkeeping for function calls; it is like a desk where each function lays out its papers while it works. Alignment is the padding the compiler inserts so that fields start at convenient addresses. This will also produce an out-of-bound inside the nft_set structure, but that is not useful for our leak.

Back to the userland

The next step is to find a way to send this information back to userland. To do so, we will use the function nf_tables_getset, in /net/netfilter/nf_tables_api.c, which can be reached in a similar way to nf_tables_newset. nf_tables_getset can be used to retrieve information about a registered set:

C
tatic int nf_tables_getset(struct sk_buff *skb, const struct nfnl_info *info,
                const struct nlattr * const nla[])
{
    const struct nft_set *set;
    struct sk_buff *skb2;
    struct nft_ctx ctx;
    int err;

    ...

    skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
    if (skb2 == NULL)
        return -ENOMEM;

    err = nf_tables_fill_set(skb2, &ctx, set, NFT_MSG_NEWSET, 0);           <===== (11)
    if (err < 0)
        goto err_fill_set_info;

    return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);            <===== (12)

}

Line by line: the function receives the request message, some info, and the attributes. It declares a pointer to the set, a second socket buffer skb2 for the reply, a context ctx, and an error variable. It allocates skb2 with alloc_skb, using GFP_ATOMIC to say the allocation must not sleep, and returns -ENOMEM if that fails. At (11), it calls nf_tables_fill_set to write the set's information into skb2. If that fails, it jumps to error handling. At (12), it sends the buffer back to the caller with nfnetlink_unicast, addressing it to the port identifier of the original sender. A port identifier here is just the address of the socket that sent the request, so the reply goes back to the right place.

This function will send data to userland through the netfilter netlink thanks to nfnetlink_unicast at (12), and this data will be set up in the call to nf_tables_fill_set, in /net/netfilter/nf_tables_api.c:

C
static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
                  const struct nft_set *set, u16 event, u16 flags)
{
    struct nlmsghdr *nlh;
    u32 portid = ctx->portid;
    struct nlattr *nest;
    u32 seq = ctx->seq;
    int i;

    event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, event);
    nlh = nfnl_msg_put(skb, portid, seq, event, flags, ctx->family,
               NFNETLINK_V0, nft_base_seq(ctx->net));

    ...

    if (set->udata &&
        nla_put(skb, NFTA_SET_USERDATA, set->udlen, set->udata))
        goto nla_put_failure;

    ...

    if (set->field_count > 1 &&
        nf_tables_fill_set_concat(skb, set))                <===== (13)
        goto nla_put_failure;

    ...

    nlmsg_end(skb, nlh);
    return 0;

nla_put_failure:
    nlmsg_trim(skb, nlh);
    return -1;
}

Line by line: the function takes the reply buffer, a context, the set, an event type and flags. It declares a header pointer, reads the port identifier and sequence number from the context, and declares a nesting marker and a loop counter. It builds the message type from the event, then writes the message header with nfnl_msg_put. If the set has user data, it copies udlen bytes from udata into the reply with nla_put; if that fails, it jumps to the failure label. At (13), if field_count is greater than 1, it calls nf_tables_fill_set_concat to add the field information; if that fails, it also jumps to failure. On success it ends the message and returns 0. On failure it trims the buffer back to the header and returns -1.

At (13), another auxiliary function is used to manage data concerning the fields field_len and field_count of the nft_set structure:

C
static int nf_tables_fill_set_concat(struct sk_buff *skb,
                     const struct nft_set *set)
{
    struct nlattr *concat, *field;
    int i;

    concat = nla_nest_start_noflag(skb, NFTA_SET_DESC_CONCAT);
    if (!concat)
        return -ENOMEM;

    for (i = 0; i < set->field_count; i++) {                <===== (14)
        field = nla_nest_start_noflag(skb, NFTA_LIST_ELEM);
        if (!field)
            return -ENOMEM;

        if (nla_put_be32(skb, NFTA_SET_FIELD_LEN,           <===== (15)
                 htonl(set->field_len[i])))
            return -ENOMEM;

        nla_nest_end(skb, field);
    }

    nla_nest_end(skb, concat);

    return 0;
}

Line by line: the function takes the reply buffer and the set. It opens a nested attribute container with nla_nest_start_noflag, returning -ENOMEM if that fails. The loop at (14) runs set->field_count times. On each iteration it opens a nested element, and at (15) it writes the value set->field_len[i], converted to network byte order with htonl, into the reply. It then closes the element. After the loop it closes the container and returns 0.

As we can see at (14), we will iterate set->field_count times, and at each iteration one element of the set->field_len buffer will be added to the socket buffer at (15). So if the off-by-one has been produced at (2) as explained previously, information stored on the stack will be copied into the heap at (10) and finally the user will be able to access it through sockets. The heap is the region of memory used for objects created while the program runs, as opposed to the stack; if the stack is the desk where a function works, the heap is the warehouse where longer-lived objects are stored.

A leak example
A leak example From the original on randorisec.fr

This leak is the result of the proof of concept. A proof of concept, or PoC, is a small program written to demonstrate that a bug is real and can be triggered.

This leak is the result of the PoC. We can observe that it allows, in these specific circumstances, to leak a stack canary and an address of the data section. A stack canary is a secret value the compiler places on the stack to detect overflows; if it changes unexpectedly, the program knows something went wrong and stops. Leaking it is valuable to an attacker because it lets them get past that protection. The data section is the part of a program's memory that holds global variables.

Limitations

We have seen that the out-of-bound can lead to an infoleak, but this leak is not very powerful because it is restricted to 28 bytes due to the organisation of the nft_set structure. Indeed, if we want a bigger leak, it requires overwriting the least significant bytes of the field udata, and it can lead to a segmentation fault in the nf_tables_fill_set function. A segmentation fault is the crash that happens when a program tries to access memory it is not allowed to touch. Moreover, the leak depends on the stack organisation, which itself depends on the compilation, so this leak can provide interesting information on a specific kernel but could also be useless on the next version.

Remediation

The researcher did not manage to turn this out-of-bound into a fully functional LPE exploit before it was publicly disclosed and fixed. It was fixed on 31 May 2022 by the commit [redacted]. A commit is a recorded change in a source code repository, with an identifier that lets anyone look it up. This commit fixes both the integer overflow and the out-of-bound. The patch of the integer overflow allows a length up to 255, which would have made exploitation of the vulnerability easier. The vulnerability was officially disclosed on oss-security, a public mailing list where security issues are announced, and the identifier CVE-2022-1972 was assigned to it.

Say LPE again! I dare you!

The nft_set structure stores several pointers, making it a good place to start. The field udata stores the address at the end of the structure, the address of the field data. If some data is stored in the field data, the number of bytes stored there is kept in the udlen field. The write primitive allows overwriting this field, which could lead to a heap infoleak. A write primitive is a reliable way to write a value of your choosing to a place of your choosing; it is the basic building block of many exploits. From this leak, one can imagine being able to get pointers from different caches. A cache here is a pool of memory blocks of the same size that the kernel reuses, so objects of similar sizes end up near each other.

One can also try to get a random free primitive with an overflow that reaches the field num_exprs of the nft_set structure and sets a value bigger than 5 (NFT_SET_EXPR_MAX = 2). A free primitive is a way to make the program release a memory block of your choosing, which can later be reused while a stale pointer still refers to it. As a result, part of the field data will also be considered part of the field exprs, and one would obtain full control over the stored exprs. One just has to find a way to call nft_expr_destroy. To do that, one may try to produce an error inside the management of the expression, just after the out-of-bound inside the nft_set structure.

By combining these techniques, one should be able to get a random free primitive and try to produce a use-after-free. A use-after-free is a bug where a program keeps using a memory block after it has been released, like reading a letter after the post office has already handed the envelope to someone else.

All of this is a hypothesis, as it has not been tested, so it may or may not work.

Conclusion

To sum up, two bugs were found within the kernel portion of netfilter, which lead to a 28-byte infoleak. These bugs could not be exploited to obtain a privilege escalation due to a lack of time and a weak write primitive (bytes should be lower than 67). All the sources of the PoC can be found on the project's GitHub.

Glossary

  • Bit: a single binary digit, 0 or 1, the smallest unit of data.
  • Buffer overflow: writing more data into a fixed-size memory area than it can hold, so the extra data spills into neighbouring memory.
  • Byte: eight bits grouped together, the usual unit for a single character or small number.
  • Cache (kernel): a pool of memory blocks of the same size that the kernel reuses for similar objects.
  • Capability: a specific permission bit in Linux, such as CAP_NET_ADMIN for administering network settings.
  • Cast: converting a value from one data type to another, sometimes losing information.
  • CodeQL: a tool that turns source code into a database so you can search for patterns with queries.
  • Commit: a recorded change in a source code repository, identified by a hash.
  • CVE: Common Vulnerabilities and Exposures, a public catalogue that gives each known vulnerability a unique identifier.
  • Data section: the part of a program's memory that holds global variables.
  • Enum: a list of named integer constants in source code.
  • Firewall: the part of a system that decides which network traffic is allowed in and out.
  • Free primitive: a reliable way to make a program release a memory block of your choosing.
  • GDB: a debugger that lets you pause a running program and inspect its variables and memory.
  • Heap: the region of memory used for objects created while a program runs.
  • Infoleak: a bug that lets someone read memory they should not be able to see.
  • Integer overflow: arithmetic that wraps around because a number exceeds the maximum the type can hold, producing a small or wrong result.
  • Kernel: the privileged core of the operating system that talks to the hardware.
  • Local privilege escalation (LPE): a way for an ordinary user to gain administrator (root) rights on the same machine.
  • Macro: a name the compiler replaces with a value or code wherever it appears.
  • Namespace: an isolated view of part of the system, so several can exist side by side without seeing each other.
  • Netfilter: the open-source packet filtering project that provides the Linux firewall.
  • Netlink: a Linux communication channel that lets ordinary programs exchange structured messages with the kernel.
  • nftables: the userland application used to configure the newer netfilter subsystem.
  • Out-of-bound: reading or writing memory outside the area a program was supposed to touch.
  • Packet: a small chunk of data travelling over a network.
  • Pointer: a value that holds the memory address of something else.
  • Proof of concept (PoC): a small program written to demonstrate that a bug is real and can be triggered.
  • Segmentation fault: the crash that happens when a program tries to access memory it is not allowed to touch.
  • Set (netfilter): an object that stores a collection of values, such as IP addresses, for rules to check against.
  • Stack: the region of memory where a program keeps local variables and function call bookkeeping.
  • Stack canary: a secret value the compiler places on the stack to detect overflows.
  • Structure: a bundle of named fields stored together in memory.
  • Table (netfilter): the object that holds all the information about one filter.
  • Use-after-free: a bug where a program keeps using a memory block after it has been released.
  • User namespace: a feature that lets an ordinary user create an isolated environment in which they appear to be root.
  • Userland: the ordinary programs you run, as opposed to the kernel.
  • Variant analysis: looking for the same kind of mistake in other places after finding it once.
  • Vulnerability: a flaw in software that can be abused to make it behave in a way its authors did not intend.
  • Write primitive: a reliable way to write a value of your choosing to a place of your choosing.

More by Arthur Mongodin

View all

1 more disclosed report, best first.

More from Linux Kernel Organization

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.