Skip to main content

CVE-2021-47546: Vulnerability in Linux Linux

High
VulnerabilityCVE-2021-47546cvecve-2021-47546
Published: Fri May 24 2024 (05/24/2024, 15:09:51 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: ipv6: fix memory leak in fib6_rule_suppress The kernel leaks memory when a `fib` rule is present in IPv6 nftables firewall rules and a suppress_prefix rule is present in the IPv6 routing rules (used by certain tools such as wg-quick). In such scenarios, every incoming packet will leak an allocation in `ip6_dst_cache` slab cache. After some hours of `bpftrace`-ing and source code reading, I tracked down the issue to ca7a03c41753 ("ipv6: do not free rt if FIB_LOOKUP_NOREF is set on suppress rule"). The problem with that change is that the generic `args->flags` always have `FIB_LOOKUP_NOREF` set[1][2] but the IPv6-specific flag `RT6_LOOKUP_F_DST_NOREF` might not be, leading to `fib6_rule_suppress` not decreasing the refcount when needed. How to reproduce: - Add the following nftables rule to a prerouting chain: meta nfproto ipv6 fib saddr . mark . iif oif missing drop This can be done with: sudo nft create table inet test sudo nft create chain inet test test_chain '{ type filter hook prerouting priority filter + 10; policy accept; }' sudo nft add rule inet test test_chain meta nfproto ipv6 fib saddr . mark . iif oif missing drop - Run: sudo ip -6 rule add table main suppress_prefixlength 0 - Watch `sudo slabtop -o | grep ip6_dst_cache` to see memory usage increase with every incoming ipv6 packet. This patch exposes the protocol-specific flags to the protocol specific `suppress` function, and check the protocol-specific `flags` argument for RT6_LOOKUP_F_DST_NOREF instead of the generic FIB_LOOKUP_NOREF when decreasing the refcount, like this. [1]: https://github.com/torvalds/linux/blob/ca7a03c4175366a92cee0ccc4fec0038c3266e26/net/ipv6/fib6_rules.c#L71 [2]: https://github.com/torvalds/linux/blob/ca7a03c4175366a92cee0ccc4fec0038c3266e26/net/ipv6/fib6_rules.c#L99

AI-Powered Analysis

AILast updated: 06/28/2025, 05:25:22 UTC

Technical Analysis

CVE-2021-47546 is a vulnerability in the Linux kernel's IPv6 networking stack that causes a memory leak in the fib6_rule_suppress function. This issue arises when IPv6 nftables firewall rules include a 'fib' rule combined with a suppress_prefix rule in the IPv6 routing rules, a configuration used by tools such as wg-quick. Specifically, the kernel leaks memory in the ip6_dst_cache slab cache for every incoming IPv6 packet under these conditions. The root cause is a logic error introduced by a commit (ca7a03c41753) that incorrectly handles reference counting due to the use of generic flags (FIB_LOOKUP_NOREF) instead of protocol-specific flags (RT6_LOOKUP_F_DST_NOREF) when suppressing fib6 rules. This results in the reference count not being decremented properly, causing a persistent memory leak. The vulnerability can be reproduced by creating specific nftables rules and IPv6 routing rules that trigger the leak, which can be observed via slabtop monitoring. The patch fixes the issue by exposing protocol-specific flags to the suppress function and correctly checking RT6_LOOKUP_F_DST_NOREF when decreasing the reference count. This vulnerability affects Linux kernel versions containing the specified commits and is relevant to systems using IPv6 with nftables and suppress_prefix routing rules. No known exploits are reported in the wild as of the publication date.

Potential Impact

For European organizations, this vulnerability can lead to gradual memory exhaustion on Linux systems heavily processing IPv6 traffic with the affected nftables and routing configurations. This could degrade system performance, cause denial of service due to resource depletion, or trigger kernel instability and crashes. Organizations relying on IPv6 networking, particularly those using VPN solutions like WireGuard (wg-quick) or custom nftables firewall rules incorporating fib and suppress_prefix rules, are at risk. The impact is more pronounced in high-throughput environments such as ISPs, cloud providers, data centers, and enterprises with IPv6-enabled infrastructure. Memory leaks in kernel space are critical as they can lead to unpredictable system behavior and require reboots to recover, affecting availability and operational continuity. While this vulnerability does not directly expose confidentiality or integrity risks, the resulting denial of service can disrupt critical services and business operations.

Mitigation Recommendations

1. Update the Linux kernel to a version that includes the patch fixing CVE-2021-47546. Monitor official Linux kernel releases and distributions for security updates addressing this issue. 2. Review and audit IPv6 nftables firewall rules and routing configurations to identify the use of fib rules combined with suppress_prefix rules. Temporarily disable or modify these rules if feasible to mitigate memory leak risk until patched. 3. Monitor system memory usage, especially the ip6_dst_cache slab cache, using tools like slabtop or other kernel memory monitoring utilities to detect abnormal growth indicative of the leak. 4. For environments using wg-quick or similar tools, verify the versions and configurations to avoid triggering the vulnerability. 5. Implement proactive system resource monitoring and alerting to detect early signs of memory exhaustion. 6. Consider deploying kernel live patching solutions if available to apply fixes without downtime. 7. Engage with Linux distribution security advisories and apply vendor-specific patches promptly. 8. Document and test firewall and routing rule changes in staging environments before production deployment to prevent inadvertent exposure to this vulnerability.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-05-24T15:02:54.829Z
Cisa Enriched
true
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9822c4522896dcbde156

Added to database: 5/21/2025, 9:08:50 AM

Last enriched: 6/28/2025, 5:25:22 AM

Last updated: 8/12/2025, 8:21:10 AM

Views: 17

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats