News for hackers. Stuff that matters.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by dheera on Monday June 24, 2024 @07:46PM (#40782479)
Why are C and C++ all of a sudden unsafe? Did I miss something?

What is safe now? JavaScript? PyTorch?

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by dequan on Monday June 24, 2024 @07:48PM (#40782495)
All of a sudden? They've been unsafe for decades, it's just that you had less of a choice then.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by ghshephard on Monday June 24, 2024 @08:00PM (#40782615)
One of the major drivers (if not the driver) for the creation of Rust the fact that C is not a memory-safe language.

This has been known for decades, but it wasn't until 2010 that a serious attempt at writing a new system-language that was memory safe was attempted and got traction - Rust.

https://kruschecompany.com/rust-language-concise-overview/#:....

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by dheera on Monday June 24, 2024 @08:05PM (#40782652)
How is C not memory safe? If I access memory I didn't allocate the OS shuts the program down. Is that not memory safety?

(Unless you're running it on bare metal ...)

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by rictic on Monday June 24, 2024 @08:13PM (#40782717)
Memory errors can be exploited by a clever adversary to control your process in a variety of unpleasant ways, see: https://en.wikipedia.org/wiki/Memory_safety#Types_of_memory_...
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by hot_gril on Monday June 24, 2024 @08:14PM (#40782732)
That's not what memory safety refers to.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by kortilla on Monday June 24, 2024 @08:24PM (#40782806)
This is not a question for HN at this point. It’s like asking why SQL query forming via string concatenation of user inputs is unsafe.

Google it, C memory boundary issues have been a problem for security forever.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by TeMPOraL on Tuesday June 25, 2024 @01:12AM (#40784727)
> It’s like asking why SQL query forming via string concatenation of user inputs is unsafe.

To be honest, that's a surprisingly deep question, and the answer is something I'm yet to see any developer I worked with understand. For example, did you know that SQL injection and XSS are really the same problem? And so is using template systems[0] like Mustache?

In my experience, very few people appreciate that the issue with "SQL query forming via string concatenation" isn't in the "SQL" part, but in the "string concatenation" part.

--

[0] - https://en.wikipedia.org/wiki/Template_processor

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by cowsandmilk on Tuesday June 25, 2024 @03:15AM (#40785436)
Really, the problem is in combining tainted input strings with string concatenation. If you have certain guarantees on the input strings, concatenation can be safe. That said, I still wouldn’t use it since there are few guarantees that future code wouldn’t introduce tainted strings.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by codetrotter on Tuesday June 25, 2024 @01:18AM (#40784759)
The problem that causes it is in photo cases that a flat string representation kind of mixes code and data. And therefore escaping (such as not allowing quotes in the user input to terminate quotes in your query, or not allowing html tags to be opened or closed by user input, nor allowing html attributes to be opened or closed by the user input, etc) is needed.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by IshKebab on Tuesday June 25, 2024 @05:28AM (#40786287)
> In my experience, very few people appreciate that the issue with "SQL query forming via string concatenation" isn't in the "SQL" part, but in the "string concatenation" part.

Really? To me it's pretty obvious that not escaping properly is the issue, and therefore the same issue applies wherever you need escaping. I don't think I've ever heard anyone say that SQL itself was the problem with SQL injection. (Although you certainly could argue that - SQL could be designed in such a way that prepared statements are mandatory and there's simply no syntax for inline values.)

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by koolba on Monday June 24, 2024 @09:10PM (#40783162)
> If I access memory I didn't allocate the OS shuts the program down.

The real problem is when you access memory that did allocate.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by dheera on Monday June 24, 2024 @10:16PM (#40783640)
So we need a new flag for gcc that writes zeros to any block of allocated memory before malloc returns, not a new language.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by KMag on Monday June 24, 2024 @11:22PM (#40784102)
You'd probably want an alternative libc implementation rather than a compiler flag.

However, calloc everywhere won't save you from smashing the stack or pointer type confusion (a common source of JavaScript exploits). Very rarely is leftover data from freed memory the source of an exploit.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by kelnos on Monday June 24, 2024 @11:25PM (#40784124)
That wouldn't make it safe. It would just make it crash in a different way, and still be vulnerable to exploitation by an attacker.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by saagarjha on Tuesday June 25, 2024 @04:25AM (#40785911)
We have that already. There are still other problems that exist.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by BlobberSnobber on Tuesday June 25, 2024 @06:31AM (#40786702)
If only the very competent people that decided to create Rust had thought of asking you for the solution instead...

Have a little humility.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by patmorgan23 on Monday June 24, 2024 @09:32PM (#40783326)
I think you have a missunderstanding on what memory safety is.

Memory safety means that your program is free of memory corruption bugs (such as buff overflow or under flow bugs) that could be used to retrieve data the user isn't supposed to have, or can be used to inject code/commands that then get run in the programs process. These don't get shut down by the OS because the program is interacting with its own memory.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by kelnos on Monday June 24, 2024 @11:23PM (#40784114)
No, that's a security vulnerability waiting for someone to exploit.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by dataking on Tuesday June 25, 2024 @03:12AM (#40785418)
Highly recommend Alex Gaynor's intro to memory unsafety https://alexgaynor.net/2019/aug/12/introduction-to-memory-un...
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by pjmlp on Tuesday June 25, 2024 @03:21AM (#40785474)
I would consider that serious attempts have been made since 1961, however all of them failed in the presence of a free beer OS, with free beer unsafe compilers.

The getting traction part is the relevance part.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by quectophoton on Tuesday June 25, 2024 @10:19AM (#40788984)
Yeah, all previous attempts at making such a language lacked two things:

1. They didn't have a big, well-known, company name with good enough reputation to attract contributors.

2. They didn't have brackets.

Success was because traction, traction was because appeal, and appeal was mostly because those two things. Nothing else was new AFAIK.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by yosefk on Tuesday June 25, 2024 @02:02PM (#40791549)
No shared mutable state in an imperative language is common, as are memory safe languages with performance close to C's? Didn't see the latter in the language shootout benchmarks, in fact Rust is much closer to C than the next closest thing
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by steveklabnik on Tuesday June 25, 2024 @02:12PM (#40791652)
I take a slightly different view of this, though I do not deny that those things are important. #1 in particular was important to my early involvement in Rust, though I had also tinkered with several other "C replacement" languages in the past.

A lot of them simply assumed that some amount of "overhead," vaguely described, was acceptable to the target audience. Either tracing GC or reference counting. "but we're kinda close to C performance" was a thing that was said, but wasn't really actually true. Or rather, it was true in a different sense: as computers got faster, more application domains could deal with some overhead, and so the true domain of "low level programming languages" shrunk. And so finally, Rust came along, being able to tackle the true "last mile" for memory unsafety.

Rust even almost missed the boat on this up until as late as one year before Rust 1.0! We would have gotten closer than most if RFC 230 hadn't landed, but in retrospect this decision was absolutely pivotal for Rust to rise to the degree that it has.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by pjmlp on Wednesday June 26, 2024 @02:36AM (#40797029)
That wasn't the case of Modula-2, Ada or Object Pascal.

Their problems was a mix of not being hieroglyph languages (too much text to type!), being much strongly typed (straitjacket programming with a famous rant post, wrongly), commercial offerings being expensive (more so against free in the box alternative), and not comming with an OS to make their use unavoidable.

Note that for all the hype, Zig is basically Modula-2 features with C syntax, to certain extent.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by steveklabnik on Wednesday June 26, 2024 @12:30PM (#40801747)
> not comming with an OS to make their use unavoidable.

Early MacOS did use Pascal, though IIRC not Object Pascal.

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by another2another on Friday June 28, 2024 @10:21AM (#40820866)
You can still find documentation for Macos toolkit with Pascal bindings.

This is a bit of a nostalgia trip for me as I owned a copy of this book way back in the 90's

https://developer.apple.com/library/archive/documentation/ma...

Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by t3rra on Tuesday June 25, 2024 @12:53AM (#40784617)
stop BS, you moron. You miss whole things OK?
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by runiq on Tuesday June 25, 2024 @02:13AM (#40785046)
Tcl
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by pjmlp on Tuesday June 25, 2024 @03:19AM (#40785462)
They have been unsafe from their very early days, Multics got a higher security score than UNIX thanks to PL/I, and C.A.R Hoare has addressed C's existence on his Turing Award in 1980, while Fran Allen has also made similar remarks back in the day.
Re:More Memory Safety for Let's Encrypt: Deploying ntpd-rs by alkonaut on Tuesday June 25, 2024 @07:40AM (#40787232)
Because you can cast a pointer to a number and back again. Then you can stuff that value into index [-4] of your array. More or less.