AIFeed

AI does not solve security. That's our job

Original text(via HN AI)

goldenstack's blog

AI does not solve security. That's our job

All this buzz about Anthropic’s latest hacking models or OpenAI “accidentally” hacking Hugging Face is causing a lot of confusion within the cybersecurity community as well as outside of it. Will AI find vulnerabilities in every piece of software and hack everyone and end the world? Some people seem to think so.

As AI ‘agents’ get increasingly capable of finding and exploiting vulnerabilities, some people seem to treat the models themselves as the problem, and thus we need to make cybersecurity-capable models increasingly difficult to access. For others, the thinking goes that perhaps you should make your software harder to inspect, by, for example, removing your source code and keeping all application logic behind closed doors.1

There is apparently a commonly-held misconception that all code is horrendously and unavoidably insecure, and that some arbitrary number of hours of external testing can always result in a critical vulnerability. Despite how the current software and cybersecurity landscape appears to promote this idea, it represents a fatalist and incorrect view of how the software engineering process works.

Economics

All that AI has changed is the economics of vulnerability research.

A human researcher might spend hours understanding a system, probing its interfaces and trying different inputs. They might get bored if they feel that they’re not getting enough carrots.

An army of persistent agents, on the other hand, can do this continuously, cheaply, and without getting bored.

Arguably, we should welcome this development, because it forces us to confront a question that software engineering has avoided for far too long:

Why are we relying on vulnerabilities being difficult to find instead of building software in which they are difficult to create?

If the existence of AI makes your software insecure, it was never secure in the first place. Security through obscurity (and complexity) has always been a weak defense, and if anything it is less of a defense in the modern age now that we have teams of ever-persistent agents to endlessly black-box test your software.

As software engineers, it’s our job to write good software, and moreover to write code that makes it harder for other engineers to make mistakes. However, we have accepted a model of security under which vulnerabilities are treated as inevitable. We write millions of lines of complicated code, release it, and then employ security researchers, automated scanners bug bounty hunters, and, increasingly, AI agents to find the mistakes.2

There is value in all of these things. We should absolutely look for bugs. Nevertheless, finding vulnerabilities individually is not a substitute for designing systems that eliminate entire classes of vulnerabilities.

AI hacking is not magic and inevitable. We just have to write better software. If we can do so, in the long term, defending against attackers is a winning game–a vulnerability has to exist in the first place before it can be exploited. Now, the real question is: how can we write secure software without making every software engineer a cybersecurity expert?3

Design

We can eliminate entire classes of vulnerabilities with safer design practices, to the extent that they are no longer a concern. This can be done in ways that intrude minimally on, or even aid, the developer experience.

Generally, upgrading existing software to resolve vulnerability classes is a form of generalization. Common techniques used to secure code can be factored out into a general system, so that certain safe patterns can be repeatedly depended on in a way where any bugs that exist are found in the original implementation itself, not the software of the engineer that uses it. When implementation issues do show up, they can be solved for everyone at once.

There are several different classes of security vulnerabilities that can be eradicated. I’ll explain two, although I assure you that there are many, many more.

Memory safety

Here’s an obvious one: memory safety. A memory allocator is already a general system for reporting lifetimes of memory, providing a safer API to manage the space that your program uses. Memory safety simply involves avoiding communicating incorrect information to the allocator.

There are lots of memory safety techniques, but they all provide the same guarantee: if your program ends up with memory safety issues, it’s a fault of the memory management system, not your own.

This is a relatively easy issue to attack, since it has been established that memory safety is an important layer to rely on.

Injection

Now, I’m going to articulate another vulnerability class, and explain exactly how we can entirely resolve it.

Injection vulnerabilities are a class of vulnerability where a parser which has syntactic structure communicated to it in-band is provided an input that is partially or fully controlled by an untrusted user, such that the untrusted input can communicate syntactic information or structure in a way that can result in user-controlled unintended behaviour.

Common examples of injection vulnerabilities include SQL injection, OS command injection, XSS, LDAP injection, and many, many more.

Less popular examples of injection vulnerabilities include, I argue, cases where user input that can contain null bytes is stored in a null-terminated string, a common issue but one which is not often thought of as injection.

Injection vulnerabilities mainly exist because shared APIs often rely entirely on strings, where all information is in-band. We can eradicate this entire vulnerability class from existence, then, by either avoiding providing user input to the parser, or by storing information out-of-band.

Prepared statements are probably the most prominent (and successful) implementation of this strategy. Prepared statements implement the fix described above, where user input is instead provided through a typed API, so that all text provided to a parser is trusted.

Besides the security implications, they’re actually an improvement over using raw strings; if a language supports string interpolation, it’s possible to write code the exact same as previously, with your SQL library internally using prepared statements to manage this integration. This also can help make your program faster, as statements only have to be parsed once.

Sanitizers are unfortunately a suboptimal solution. It’s incredibly easy, and happens extremely often in the real world, for the sanitizers’ parser reimplementation to diverge from the original, or for the standard to be ambiguous such that multiple valid parsers nevertheless have different behaviour. Sanitizers should only exist if they have a direct dependency on the actual parser code, eliminating the possiblity of desynchronization.

Accessible formal methods

As explained above, we can eliminate entire vulnerability classes if we solve problems once. Overall there is not a single blueprint for how to solve problems once, but I argue that some memory safety strategies, as well as prepared statements, are only able to accomplish as much as they do because they make increased usage of types.

Types themselves are already a solution to a class of vulnerabilities, and they’re so useful because they allow asserting compile-time knowledge about runtime values, making them “zero-cost.”4

As programs are proofs, types are really just a special case of formal methods. Really, types are accessible formal methods: they don’t ask much from the user, yet they act implicitly as proofs instead of forcing the programmer to spell them out.

My point, then, is that we need accessible formal methods in order to make our programs more secure, and AI has only made this more apparent. This should be obvious, really: if you prove that your programs are secure, then either you can simply know that they’re secure, or you’ve found a soundness bug in your proof engine.

LLMs

Despite the inflammatory title of this post (which might have more aptly been “The case for accessible formal methods”), LLMs still play a part in this proposal. After all, LLMs are good at writing proofs, so we should take advantage of this.

There are two directions from which we can approach useful and accessible formal methods: either make existing accessible formal methods more useful, or make existing useful formal methods more accessible. My suggestions involve the latter, but Ron Minsky believes in the former, writing that “our hope is to make formal methods as pervasively useful of a tool for building software as sophisticated type systems are for us today.”5

We can use LLMs to write our proofs, with the remaining concerns being that “the code proves the correct statement” and, potentially, performance issues.

While demonstrating the efficacy of LLMs at scale is beyond the resources available to me (the frontier labs can do this; I’m not employed at any of them, though), their potential is clear: AI and formal methods work hand-in-hand. Formal methods provide the rigor that AI models don’t bring to the table, while AI can make formal methods more accessible and practical. Once again, examining specifically how to implement this is an active research area, so the exact potential is still undetermined.

Closing thoughts

AI has made finding vulnerabilities cheaper, but it has not made them inevitable. We have the tools to eliminate entire classes of vulnerabilities, and, increasingly, the means to make those tools accessible to everyone. The future of software security should not depend on our ability to find mistakes faster than the attackers, but on our ability to prevent those mistakes in the first place.

It is within our collective power to make software more secure. We just have to decide to put in the effort to do so.

Thank you Varun Biniwale for helping write this article and contributing many of the ideas used.

“The best way to make sure things are secure is to make it impossible to be insecure.” - Raymond Chen, “The Old New Thing”

Footnotes

  • Taking down previously-public open-source code is a strange strategy. Not only does removing the repository not make the source code disappear, but even if nobody has a copy of the source, black-box testing often works just fine. ↩
  • Vulnerability research economics has already been changed in the past; it’s just even more different now. When effective fuzzing was first introduced, we didn’t see the existence of AFL++ and OSS-Fuzz suddenly make software secure, even though they have found thousands of bugs. ↩
  • I don’t think AI is the solution to this either. It is important that you understand what your software does across at least one entire layer of abstraction, and AI cannot provide an opaque layer to accomplish this. Software engineers should be at least vaguely aware of cybersecurity principles, even if they’re not experts. ↩
  • “Zero-cost” is an insufficient phrase because any abstraction that makes you write your code differently must have a cost, but I digress. ↩
  • Bend also seems intriguing–I’ve been following Victor Taelin since HVM1–but I have yet to be convinced of its effectiveness. ↩

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗