Hacker News new | ask | show | jobs
by mjb 12 days ago
In my experience, LLMs are surprisingly good at it. Especially transforming user-visible promises (like "all transactions are replicated to three nodes before being acknowledged") into high-quality specifications. I'm not entirely clear on what it means, specifically, for this transformation to be sound or unsound. What definition do you have in mind?

What have you tried that isn't working?

Completeness is harder, for sure. Maybe not tractable, especially in context of the whole universe (which is a point OP makes). Applicability is pretty easy - it's a NLU problem, and we're pretty good at those so far.

3 comments

I can give a real-life example. WPA2 was formally verified at the protocol level, but the formal specification -- while reviewed by multiple humans -- was flawed, which directly led to the KRACK attack.

The Needham-Schroeder Public-Key Protocol failed to include the responder's identity in the protocol, which led to a man-in-the middle attack found via model checking. This is despite numerous proofs -- some even machine-checked -- of implementations against specification.

When cryptocurrencies had their formal methods moment a few years ago, there were numerous vulnerabilities and attacks found in cryptocurrency protocols despite claims of being formally verified, and despite much of this verification being published in Rocq, Lean, etc. If the specifications are unsound or flawed, then the implementations will also be. While in these cases, it's quite clear that the folks performing the formal methods work were likely inexperienced, I don't see how an LLM will create anything more sound.

Remember that an LLM is trained on publicly available information. It's not going to make a leap above and beyond what has been published openly, and much of what has been published with respect to security is related to student projects (e.g. "Let's build a formally verified AES implementation") or one-off applications, some of which, like WPA2 KRACK, have incomplete specifications.

This is a difficult problem that experienced proof engineers get wrong, after performing rounds of threat modeling and review.

KRACK relies on nonce reuse, which as the word "nonce" implies, is something that you must not do.

Any formal specification that doesn't include the invariant about a nonce not being reused isn't worth anything at all.

So yes, incompetent people can design insecure specs that fail to state even the most basic security properties we know of.

It's not just a matter of competence: it's a matter of knowledge, experience, and tenacity. Currently, frontier model companies are trying to tackle the problem of their models writing potentially unsafe software by demonstrating that their models can build formal proofs. However, someone who lacks formal verification experience, the domain knowledge to make such software safe, or the understanding to combine the two into formal specifications will build bad proofs, because the formal specifications will be unsound. LLMs don't necessarily improve this outcome. An inexperienced engineer, with or without LLM assistance, is just as likely to not add a property to verify that nonces aren't re-used as the WiFi Alliance.

WPA2 wasn't designed by a single individual. It was designed by a committee of people including respected cryptographers and information security folks. They missed the fact that nonces could be re-used in the design, and they trusted the formal specifications that lacked a check on nonce re-use. It happens. Unfortunately, formal specifications tend to trap folks into a sense of complacency. Soundness is a hard problem, and if it's not solved, folks will make bad assumptions. "But, it's been formally verified..."

Could LLMs accelerate tactics and Curry-Howard level hole filling of specifications? Absolutely. But, they aren't likely to do much better than humans at building sound specifications. This is a difficult problem, for experienced humans with a narrow specialization in formal methods.

Do you foresee AIs (not necessarily of the LLM kind) getting smarter enough to build proper proofs?
The flaw exploited by KRACK was not in the proof. I thought that was obvious.

It's that a key property, that a nonce (a number only used once) was never reused, was never stated. So that property was not proven, and in fact, was false.

It takes one line of specification to state the nonce invariant. It is beyond incompetent to leave it unstated.

Once stated, any proof would have to also satisfy that invariant (and the existing proofs would, of course, fail since the current design does not prevent nonce reuse).

It's difficult to speculate about the future. We don't yet have the right kind of hardware -- whether it be performance, scale, etc -- to simulate the kind of synthetic intelligence necessary to outpace humans at reasoning.

It's not a matter of constructing proofs. This can be done via brute force with appropriately managed search trees. LLMs actually are not much better at this than other ML or search techniques; it's just that in practice, that's not what proof engineers have optimized for.

Building a sound specification, that as erichocean pointed out, would include measures to prevent nonce re-use, is a much more subtle and difficult thing. You can prove that software is correct with respect to a specification, but there is nothing beyond proving internal consistency, to verify that the specification itself is sound, complete, or appropriate. This is an open-ended problem, and one that humans have difficulty with. I don't think that any synthetic intelligence is likely to do better, because it can only do as well as the vetting of information provided to it, and it is very likely that this information will be flawed and incomplete. LLMs try to fill in the blanks with plausible things, based on their training. Even humans make assumptions. These assumptions are sometimes wrong.

Regarding proof automation, this is actually a double-edged sword. I can build systems today that will perform various optimization techniques to try to get further into a proof via tactic search, and will eventually converge on a solution. However, the tactics will be a mess, much like the 1600 pages of tactics in the OpenAI NS proof. A good proof engineer builds specifications and proofs that other humans can read and understand. Even the tactics are organized around what can be explained, so that these can be hand checked. If you're building proofs of software, you want auditors to be able to look at these as well as the specification to see if you are missing something, such as a nonce re-use policy.

In this case a reasonable conclusion would be that there are no sufficiently competent people and we should act on that basis. Or, at least, that we have no reliable way of marrying sufficient competence with the right problems.
> there are no sufficiently competent people

The common countermeasure to omissions and mistakes is a social measure: we bring talented people together to work as a team.

Even doing so, failures happen. Wise people know the value of testing.

Well yes, but this case is specifically about a time when the right thing wasn't tested for, because the team of wise, talented people attached missed it.
I regret to inform you that the word nonce implies something else entirely in the UK
I disambiguate by saying "cryptographic nonce" at work.
I think OP is referring to more of a fundamental problem that a spec has to be written down, and if it's not then AI is just guessing. Often it makes very good guesses, but it can fundamentally never solve the problem of producing a complete specification when the user hasn't got a "complete" picture in their mind.

In my own practical experience this is now what software development is about. If you can specify what you want, AI can implement it. But specifying it is actually very time consuming and hard.

In a sense every prompt you send to an LLM is a specification. And its tedious to write all those prompts, I feel. You have to be very precise, and also write it all into the prompt. And even then answers I get from the LLM are often lacking so I have to prompt again, and then often the LLM replies that it now agrees its previous answer indeed was wrong or inapplicable.
I agree, but that's the job now.
One obvious issue is that an LLM can claim it has formally verified your spec, only for careful inspection to reveal that the spec was subtly changed in some way during translation. Meanwhile the LLM continues to claim it implemented the spec exactly, then pulls a "you're absolutely right and here's why" when you point out the issue.

I think everyone who has used LLMs for coding will have run into this at some point, so it's not very convincing that LLMs are good at this sort of thing.

We have the case of the paper version of OpenAI's Navier-Stokes work turning out to be describing something slightly different from the Lean formalization, as a more public example.