Hacker Newsnew | past | comments | ask | show | jobs | submit | ulan's commentslogin

I guess the authors used a raw allocation in the example code to show the simplest possible use-after-free.

Any software with complex object ownership written in a language without GC has to balance between user-after-free (freeing an object too early) and memory leaks (keeping an object alive longer than needed). Maybe constructing secure code here would mean simplifying object ownership, but that doesn't seem practical for a beast such a modern browser with millions of lines of code.

MTE with the heap scanning sounds like a real solution for the user-after-free problem, not merely a mitigation. The trade-off is that the memory is not immediately freed, but the measured increase of only 1% is promising.


https://smallcultfollowing.com/babysteps/blog/2022/06/15/wha... Gives a good example (in rust) of a case where complex object ownership could lead to a bug. The summary of the example there looks like:

- you have some AST object and want to lower it in the compiler into an intermediate representation

- you want to add some interesting parts of the AST to your state while lowering and refer to them later in the lowering process

- This seems fine: the AST is first created, then you lower to the intermediate representation, then you can destroy the AST, so while you’re doing the lowering, the AST objects should all be alive and therefore ok to store references to in the lowerer-state

- However there is some mostly unnoticed code that is roughly desugaring some syntax by constructing temporary AST nodes

- So your addition may have your state including references to these temporary nodes

- And those temporary nodes are freed shortly after being created rather than after the lowering is all done

- Giving a quite subtle use-after-free.


It isn't a complete solution because it does not address stack-allocated data but it is very very close to being a full solution.


Author here. Fingerprinting is a valid concern. The API explainer has a section about it: https://github.com/WICG/performance-measure-memory#fingerpri...

It is important to keep in mind that the API only accounts for the objects allocated by the web page itself and does not expose the total memory usage of the browser.

The only information that can be extracted using the API is the browser version (because an object representation may change between different versions) and the bitness of the browser (32-bit vs 64-bit). This information is already exposed by other existing APIs (e.g navigator.userAgent, navigator.deviceMemory)

Thus the API does not add _new_ data bits for tracking. The final spec of the API may include additional protection against fingerprinting. For example, adding a small amount of Gaussian noise would make browser version inference much more difficult.


Author here.

The new API excludes the objects allocated by extensions, so the results should be more stable and actionable compared to the existing tools.

I filed a feature request for DevTools heap snapshot to do the same: https://bugs.chromium.org/p/chromium/issues/detail?id=107093...


I like how the author contrasts monads with applicative functors and demonstrates why monads are more powerful.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: