Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ ZDI-20-1440: An Incorrect Calculation Bug in the Linux Kernel eBPF Verifier

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š ZDI-20-1440: An Incorrect Calculation Bug in the Linux Kernel eBPF Verifier


๐Ÿ’ก Newskategorie: Hacking
๐Ÿ”— Quelle: thezdi.com

In April 2020, the ZDI received a Linux kernel submission that turned out to be an incorrect calculation bug in the extended Berkeley Packet Filter (eBPF) verifier. If youโ€™re not familiar with it, eBPF is a Linux subsystem that is designed to safely execute untrusted, user-defined extensions inside the kernel for purposes such as packet filtering. It relies on static analysis to protect the kernel against problematic extensions. The submission we received from Ryota Shiga (@Ga_ryo_) of Flatt Security bypasses the eBPF verification and can lead to out-of-bounds (OOB) access in the Linux kernel. The eBPF verifier is a well-known source of Linux kernel local privilege escalation vulnerabilities and has been seen in many cases in the past, including being used atย Pwn2Own 2020.

This vulnerability affects the current Linux kernel long term version from 4.9 to 4.13. One particular distribution, Debian 9, is currently using an affected kernel version. The ZDI is disclosing this bug publicly asย ZDI-20-1440 without a patch in accordance with our 120-dayย disclosure policy.

The Vulnerability

If you are not familiar with the eBPF verifier, we highly recommend the write-up by Manfred Paul (@_manfp). There are two passes of verifications before executing any BPF programs. The first pass (check_cfg()) ensures the code is loop-free. The second pass (do_check()) attempts to determine if there are any invalid instructions or possible memory violations. Emulation is used to check for possible memory violations. The incorrect calculation described here comes from opcode BPF_RSH during the second pass. The following excerpts are based on 4.9.249.

The BPF_RSH (unsigned right shift) instruction belongs to the BPF_ALU64 class of instructions. When emulating BPF_RSH, do_check calls check_alu_op at (1), which then calls adjust_reg_min_max_vals at (2). At (3) and (4), it tries to update the minimum and maximum value of dst_reg based upon how the shift operation will modify dst_reg. Note that the local variables min_value and max_value contain the known bounds of the operand that specifies the shift distance. There are corresponding fields named min_value and max_value that hold the known bounds of dst_reg.

However, the calculations at (3) and (4) are wrong. For example, to calculate max(a >> b) (the maximum possible value of a when right-shifted by b bits), the correct formula is max(a) >> min(b). (To understand why, consider that a right shift is equivalent to division by a power of two. The largest possible result is produced by choosing the largest possible numerator and the smallest possible denominator.) Instead, the code at (4) calculates max(a) >> max(b). A corresponding mistake is present at (3).

The consequences of bounds miscalculation during eBPF verification are catastrophic. If the attacker later uses dst_reg as the address for a load or store, the verification in (5) below will be bypassed.

Once the eBPF program passes verification, it will execute in the kernel, and the attacker can achieve an out-of-bounds memory access, as seen in (6) below.

The Trigger

Before triggering the bug, we have to first create two bpf maps with bpf_create_map(). A bpf map is a memory region designated to be accessible from within eBPF code. One map is for triggering the bug, while the other is the target for OOB access. The following opcodes perform preliminary work:

The BPF_FUNC_map_lookup_elem function returns a pointer to a location in a bpf map. After execution of the code shown above, BPF_REG_8 and BPF_REG_9 are set to the values from map1[1] and map1[2] respectively. They will be used as operands for BPF_RSH. The final BPF_GET_MAP shown above loads BPF_REG_0 with a pointer to map2[0].

The next step is to get the verifier to recognize that the operands to BPF_RSH will be bounded within a certain range. Here are the opcodes to limit the range of the registers by using branches.

The verifier will correctly deduce that execution cannot fall through past these instructions unless 0 <= REG_8 <= 0x1000 and 0 <= REG_9 <= 1024. (Note that JA means โ€œjump alwaysโ€, not โ€œjump if aboveโ€ as in x86.)

It's time to trigger the bug.

After the BPF_RSH instruction, BPF_REG_8 can still have a value as high as 0x1000. But due to the incorrect computation discussed above, the verifier concludes that the maximum possible value of BPF_REG_8 is now 0. On the basis of this, the verifier incorrectly concludes that the memory operation at (B) is guaranteed to be safe.

BPF_STX_MEM at (B) will perform an OOB write on map2 with an arbitrary offset specified by BPF_REG_8.

However, there is one additional precondition. Recall from above that when encountering an instruction that operates on memory, the verifier performs checks in a function named check_mem_access(). When the address of the memory operation is controlled by a register, check_mem_access() additionally ensures that the verifier has already marked the register contents as PTR_TO_MAP_VALUE or PTR_TO_MAP_VALUE_ADJ. The verifier will only set this mark if the allow_ptr_leaks flag is enabled in the environment, and to enable this flag, the caller must have the CAP_SYS_ADMIN capability.

This means CAP_SYS_ADMIN is required to trigger the bug, even if the eBPF program is attached to a socket owned by the attacker.

Conclusion

Although the precondition reduces the impact and risk, it would still be better to apply thisย mitigation, or even better, upgrade the kernel to an unaffected version. Our team will try to follow up on the patch when it is released. Thanks again to Ryota Shiga of Flatt Security for submitting this bug. Heโ€™s submitted a few other reports to the program, and each has been great. We hope to see more from him in the future.

You can find me on Twitterย @_wmliang_, and follow theย teamย for the latest in exploit techniques and security patches.

...



๐Ÿ“Œ CVE-2021-31440: An Incorrect Bounds Calculation in the Linux Kernel eBPF Verifier


๐Ÿ“ˆ 76.32 Punkte

๐Ÿ“Œ CVE-2021-31440: An Incorrect Bounds Calculation in the Linux Kernel eBPF Verifier


๐Ÿ“ˆ 76.32 Punkte

๐Ÿ“Œ Linux Kernel up to 4.11.0 eBPF Verifier Log kernel/bpf/verifier.c print_bpf_insn System Calls information disclosure


๐Ÿ“ˆ 66.19 Punkte

๐Ÿ“Œ CVE-2021-4159 | Linux Kernel ebpf Verifier kernel/bpf/verifier.c adjust_scalar_min_max_vals dst_reg unknown vulnerability


๐Ÿ“ˆ 66.19 Punkte

๐Ÿ“Œ Linux Kernel Extended BPF Verifier kernel/bpf/verifier.c Denial of Service


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel up to 4.14.8 Extended BPF Verifier kernel/bpf/verifier.c information disclosure


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel 4.9.x Extended BPF Verifier kernel/bpf/verifier.c memory corruption


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel bis 4.14.8 Extended BPF Verifier kernel/bpf/verifier.c Information Disclosure


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel 4.9.x Extended BPF Verifier kernel/bpf/verifier.c Pufferรผberlauf


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel Extended BPF Verifier kernel/bpf/verifier.c denial of service


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel up to 4.14.x/4.15.x/4.16.x/4.17.x/4.18.12 BPF Verifier kernel/bpf/verifier.c adjust_scalar_min_max_vals memory corruption


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel up to 5.4.28/5.5.13/5.6.0 BPF Verifier kernel/bpf/verifier.c) memory corruption


๐Ÿ“ˆ 49.92 Punkte

๐Ÿ“Œ Linux Kernel up to 5.11.14 eBPF calculation


๐Ÿ“ˆ 42.65 Punkte

๐Ÿ“Œ [dos] Linux Kernel 4.11 - eBPF Verifier Log Leaks Lower Half of map Pointer


๐Ÿ“ˆ 42.48 Punkte

๐Ÿ“Œ Linux Kernel eBPF Code Verifier dev_map_init_map/sock_map_alloc out-of-bounds read


๐Ÿ“ˆ 42.48 Punkte

๐Ÿ“Œ eBPF 4.9-stable Verifier Bug Backported


๐Ÿ“ˆ 41.04 Punkte

๐Ÿ“Œ eBPF 4.9-stable Verifier Bug Backported


๐Ÿ“ˆ 41.04 Punkte

๐Ÿ“Œ CVE-2023-24533 | filippo.io nistec prior 0.0.2 P-256 Scalar Calculation calculation


๐Ÿ“ˆ 39.1 Punkte

๐Ÿ“Œ Escalating privileges through the Linux eBPF verifier


๐Ÿ“ˆ 38.14 Punkte

๐Ÿ“Œ CVE-2023-39191 | Linux Kernel eBPF input validation (ZDI-23-1489)


๐Ÿ“ˆ 38.06 Punkte

๐Ÿ“Œ VED-eBPF - Kernel Exploit And Rootkit Detection Using eBPF


๐Ÿ“ˆ 36.88 Punkte

๐Ÿ“Œ [dos] Microsoft Edge Chakra JIT - Incorrect Bounds Calculation


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ Microsoft Edge Chakra JIT Incorrect Bounds Calculation


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ Microsoft Edge Chakra JIT Incorrect Bounds Calculation


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ #0daytoday #Microsoft Edge Chakra JIT - Incorrect Bounds Calculation Exploit [dos #exploits #0day #Exploit]


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ Chromium Incorrect Size Calculation Out-Of-Bounds Access


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ Chromium Incorrect Size Calculation Out-Of-Bounds Access


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ Python Documentation 2/3 Sorting Incorrect Calculation


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ CVE-2022-31169 | Wasmtime up to 0.38.1 Cranelift incorrect calculation (GHSA-7f6x-jwh5-m9r4)


๐Ÿ“ˆ 33.84 Punkte

๐Ÿ“Œ GitHub - Nalen98/eBPF-for-Ghidra: eBPF Processor for Ghidra


๐Ÿ“ˆ 32.55 Punkte

๐Ÿ“Œ microsoft/ebpf-for-windows | eBPF for Windows


๐Ÿ“ˆ 32.55 Punkte

๐Ÿ“Œ loxilb (eBPF based LB) now implements IPVS rules using eBPF


๐Ÿ“ˆ 32.55 Punkte

๐Ÿ“Œ eBPF Tutorial by Example: Learning eBPF Step by Step with Tools


๐Ÿ“ˆ 32.55 Punkte

๐Ÿ“Œ eBPF Arbitrary Read/Write Via Incorrect Range Tracking


๐Ÿ“ˆ 30.56 Punkte











matomo