News for hackers. Stuff that matters.
Re:Glibc getaddrinfo stack-based buffer overflow by lmm on Tuesday February 16, 2016 @10:39AM (#11110522)
It would be a wasted effort. Anything that's using glibc (directly) is written in C and therefore inherently unsafe. There are only two kinds of programs written in C: those that need to do unsafe things and those whose developers don't care about safety. Better to look to building systems that don't need to run any C code (see the recent fuss around unikernels).
Re:Glibc getaddrinfo stack-based buffer overflow by qb45 on Tuesday February 16, 2016 @11:39AM (#11111047)
> Anything that's using glibc (directly) is written in C

... and together with stuff using glibc (indirectly) constitutes 99.99% of your software.

How much software/languages implement their own DNS resolver instead of just calling libc? How about syscall wrappers?

Re:Glibc getaddrinfo stack-based buffer overflow by lmm on Tuesday February 16, 2016 @12:03PM (#11111266)
The JVM looks to have its own implementation. I imagine .net would be the same. There's ocaml-dns for unikernel-deployed OCaml.

A managed language generally doesn't give you direct access to syscalls at all. In rust you can perform them without having to go via C.

Re:Glibc getaddrinfo stack-based buffer overflow by zwetan on Tuesday February 16, 2016 @01:50PM (#11112163)
With Redtamarin (based on AVM2), there is a native library which sole purpose is to give direct access to C and other syscalls.

For ex with getaddrinfo: https://gist.github.com/zwetan/0c047d36542cc6979652

I know because I did it on purpose, even if it managed code written in AS3 you don't want to reinvent getaddrinfo, you want to reuse it "as is" as much as possible.

Re:Glibc getaddrinfo stack-based buffer overflow by gpderetta on Tuesday February 16, 2016 @12:45PM (#11111660)
Note that DNS lookup doesn't require any syscall other than normal socket i/o, which is available on any non toy language.

One possible reason why java might implements its own name resolution is because it wants to do async name resolution which is not possible (at least portably) via getaddrinfo and friends.

Re:Glibc getaddrinfo stack-based buffer overflow by spc476 on Wednesday February 17, 2016 @12:48AM (#11115623)
Yes, but you still need to encode the questions and decode the answers. Existing libraries that do this are pretty dismal.

(Dismal enough that I ended up writing my own DNS encoding/decoding library (https://github.com/spc476/SPCDNS) with the aim of being easy to use as well as safe. It assumes nothing about the incoming packet and does extensive validation (enough that it found bugs in other DNS libraries). It also avoids dynamic memory allocations. It's used at work in two projects that get heavy use (millions of DNS queries a day) and so far has performed without incident, so well written C code is possible.)

Re:Glibc getaddrinfo stack-based buffer overflow by fpoling on Tuesday February 16, 2016 @12:03PM (#11111267)
The problem is not C as one can compile C into NaCl or asm.js and get memory safe code. One can also use a number of static checkers. The real problem is that even this is not done in cases when using C is a must due to project nature.
Re:Glibc getaddrinfo stack-based buffer overflow by gpderetta on Wednesday February 17, 2016 @05:09AM (#11116751)
Compiling to NaCl or asm.js doesn't make an arbitrary C program memory safe. It "merely" prevents any memory safety failure to affect anything outside the container.

This is different from, for example, java bytecode which is verified and guaranteed to be memory safe.

This is not a mere technicality: an heartbleed vulnerable version of openssl compiled on top of asm.js or NaCl would still leak secret information.

edit: typo

Re:Glibc getaddrinfo stack-based buffer overflow by fpoling on Wednesday February 17, 2016 @01:41PM (#11120146)
Both asm.js and NaCl guarantee execution stack integrity and allow jumps only at predefined targets in code making exploiting bugs like this highly problematic. Data-only exploits are hard and in asm.js case they are father limited as access outside of the memory leads to program termination.

On the other hand memory safety does not prevent bugs like Heartbleed or resent OpenSSH key leak. As the underling issue is related to broken reuse of a cached buffer, such code can be written in Java or even Rust just as well.

Re:Glibc getaddrinfo stack-based buffer overflow by gpderetta on Thursday February 18, 2016 @03:18AM (#11124411)
Sure, but these are (very effective) mitigation techniques, but still do not guarantee memory safety.

You are right that Heartbleed is not a memory safety issue, I should have been more careful. I just wanted an example of an exploit that doesn't need to escape the process boundary to cause damage.