ltp icon indicating copy to clipboard operation
ltp copied to clipboard

regtest for ebpf input validation CVE-2022-23222

Open msmeissn opened this issue 2 years ago • 5 comments

via oss-sec

The exploit code can be found at https://github.com/tr3ee/CVE-2022-23222

msmeissn avatar Jun 07 '22 10:06 msmeissn

AFAICT there is no fix for this or #944. We are just relying on /proc/sys/kernel/unprivileged_bpf_disabled > 0?

I'm tempted to say that it's not worth implementing a test that we know will fail unless some setting is applied. OTOH it appears very simple to do the OOB write and corrupt memory. So it can be used to assert /proc/sys/kernel/unprivileged_bpf_disabled should be > 0.

@metan-ucw

richiejp avatar Jun 20 '22 14:06 richiejp

Actually IIRC unprivileged bpf doesn't allow pointer arithmetic after a certain version. So we are not just relying on unprivileged_bpf_disabled

richiejp avatar Jun 20 '22 14:06 richiejp

I guess that it makes sense to write the test in a case that the support for userspace eBPF will be enabled back again one day, which may happen one day due to containers.

metan-ucw avatar Jun 22 '22 09:06 metan-ucw

Well I reproduced #944 easily. However this one is slightly more complicated and the PoC doesn't quite match the description.

" First, we pass 0xffff........ffff to BPF_FUNC_ringbuf_reserve to get a NULL pointer r0"

However they appear to pass PAGE_SIZE in the PoC. I guess I'm missing something or else this can just be substituted with the correct value. So it shouldn't be too hard either.

Also it turns out I am wrong about ptr arithmetic. It's being expanded and contracted as more code is allowed then denied again when vulnerabilities are found. There are specific fixes for these issues as well.

richiejp avatar Jun 23 '22 10:06 richiejp

Turns out that PAGE_SIZE is too much so it does return 0. Anyway I submitted tests based on both reproducers. Possibly they are just different ways of triggering the same issue.

richiejp avatar Jul 04 '22 12:07 richiejp