CARVIEW |
Select Language
HTTP/2 200
date: Tue, 07 Oct 2025 07:42:46 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"c8f74983cd6bdef3a826b5ba756d2ef9"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=%2FCd%2FHlSJNSD3jRSxn4omO5dp3uc4rSrFKZ4g3N3dRDtRF4s7SwXwoRPpcHsNzjvXBL6dx8wpta0DvDUW85P5q97m7%2BjCWCOiF47GObQlPbcHl2SJwsE12uV%2FEedJ65DTZnhqJzZfYNv7U2uPlUkXC9WKlKcVYCqTB2FPytWeE1lqRZBTaRXLeroPx%2Fitqrkw7k4aQAnSf%2B%2F%2FqvSYSNYiRjhTXglbnX%2BVooz2VEFim55SFJC4oQ1NZ8A1zKiCmCV2VfHvx6kWZy6Ok9fKbcKfIA%3D%3D--5%2F3YbQFRemwp2Jjl--yhoOq1Eoy7tDK7mPMFiFGQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.660585568.1759822966; Path=/; Domain=github.com; Expires=Wed, 07 Oct 2026 07:42:46 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Wed, 07 Oct 2026 07:42:46 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: D788:113306:815F56:A06D2A:68E4C476
Linux: Heap Out-Of-Bounds Write in xt_compat_target_from_user · Advisory · google/security-research · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 493
Linux: Heap Out-Of-Bounds Write in xt_compat_target_from_user
High
Package
Linux Kernel
Affected versions
>=2.6.19 (9fa492cdc160cd27ce1046cb36f47d3b2b1efa21)
Patched versions
5.12 (b29c457a6511435960115c0f548c4360d5f4801d), 5.10.31, 5.4.113, 4.19.188, 4.14.231, 4.9.267, 4.4.267
Description
You can’t perform that action at this time.
Linux: Heap Out-Of-Bounds Write in xt_compat_target_from_user
Summary
A heap out-of-bounds write affecting Linux since v2.6.19-rc1 was discovered in
net/netfilter/x_tables.c
.Severity
High
The compat IPT_SO_SET_REPLACE/IP6T_SO_SET_REPLACE setsockopt implementation in the netfilter subsystem in the Linux kernel allows local users to gain privileges or cause a denial of service (heap memory corruption) via user namespace. This vulnerability is very similar to CVE-2016-3134 (CVSSv3 8.4 High) and CVE-2016-4997 (CVSSv3 7.8 High).
Proof Of Concept
Compile the code below using
gcc -m32 -o poc poc.c
and run it. The following panic has been observed on Linux 5.4.73 with KASAN:poc.c
Analysis
Vulnerability
The vulnerability was introduced in commit 9fa492cdc160cd27ce1046cb36f47d3b2b1efa21.
When
IPT_SO_SET_REPLACE
orIP6T_SO_SET_REPLACE
is called in compat mode, kernel structures need to be converted from 32bit to 64bit. Unfortunately, the allocation size for the conversion is not properly calculated, leading to a few bytes of zero written out-of-bounds inxt_compat_target_from_user()
. By pushing the structure size to the boundary, adjacent objects on the slab can be corrupted.Hereby, we demonstrate the IPv6 path that results in 4 bytes being written at offset 0x200 of a 512-bytes allocation:
When
IP6T_SO_SET_REPLACE
is called in compat mode,compat_do_replace()
is invoked which copies the argument from userland to kernel and then proceeds to calltranslate_compat_table()
.The function
translate_compat_table()
then checks all entries for validity and computes the new structure size which is to be allocated bynewinfo = xt_alloc_table_info(size)
. The problem here is thattarget->targetsize
is not taken into account, but onlyXT_ALIGN(target->targetsize) - COMPAT_XT_ALIGN(target->targetsize)
fromxt_compat_target_offset()
. Spoiler: Using the data structure from the PoC above, the object is allocated in the kmalloc-512 slab.Next, it proceeds to call
compat_copy_entry_from_user()
withnewinfo->entries
as destination, which starts at offset 0x40.The subroutine
compat_copy_entry_from_user()
convertsstruct ip6t_entry
,struct xt_entry_match
andstruct xt_entry_target
entries:For
struct ip6t_entry
, the destination pointer is advanced bysizeof(struct ip6t_entry)=0xa8
bytes. At this point, the destination pointer is at offset 0xe8.For
xt_entry_match
,xt_compat_match_from_user()
is called which advances the pointer bysizeof(struct xt_entry_match)=0x20
,sizeof(pad)=0xd0
, and an additional 4 bytes alignment forstruct ip6t_icmp
. At this point, the destination pointer is at offset 0x1dc.Finally, for
struct xt_entry_target
,xt_compat_target_from_user()
is called:Here,
memset(t->data + target->targetsize, 0, pad);
is of our interest. As mentioned before,target->targetsize
is not taken into account for the allocation size - only the difference between the alignments. As such,t->data + target->targetsize
may be out-of-bounds (withNFLOG
target, it can even be up to 0x4C bytes out-of-bounds!). For our example, we useNFQUEUE
as target as it has a simple structure:With that as target,
target->targetsize
will be 4 bytes andpad = XT_ALIGN(target->targetsize) - target->targetsize;
, which ispad = (target->targetsize + 7) & ~7 - target->targetsize
, will thus be 4 bytes as well. The fielddata
ofstruct xt_entry_target
is at offset 0x20, andt
isnewinfo + 0x1dc
as previously shown. As such, we can deduce the following offset formemset()
:Exploitability
This vulnerability can be exploited by partially overwriting the
m_list->next
pointer of themsg_msg
structure and achieving a use-after-free. This is powerful enough to gain kernel code execution while bypassing KASLR, SMAP and SMEP.Syzkaller
While the vulnerability was found by code auditing, it was also detected once by https://syzkaller.appspot.com/bug?id=a53b68e5178eec469534aca80fca1735fb3d8071, however not with a reproducible C code.
Timeline
Date reported: 2021-04-06
Date fixed: 2021-04-13
Date disclosed: 2021-07-07