ai newsDi., 1. Dez.

KI findet Sicherheitslücken schneller als sie gestopft werden können

Facts in the opening, and how far each was checked on 2026-11-19: 63 / 44 / 32 / 5 days: read on the Google Cloud page itself (post of 2024-10-15, 138 vulnerabilities, mean, measured against the patch release). The page also says that the 2023 mean is 47 days when the outliers stay in. I left that

dev.toDonnerstag 19:29 · 19.11.DE8 Min. Lesezeit
Bild: dev.to

Fakten in der Einleitung und wie weit jede davon am 2026-11-19 geprüft wurde:

Alles über das Repository stammt aus v1 und wurde dort geprüft: 197 Tests bestanden und 2 übersprungen, die Tests gegen einen echten Server bestanden, 80.000 / 8.334 / 58 / 0 aus articles/behaviorlock/v1compare, die Log-Zeile und die Statuscodes aus der Beispiel-API im Enforce-Modus. Leistungszahlen sind aus der README übernommen und wurden nicht erneut gemessen.

2018 und 2019 brauchten Angreifer im Schnitt 63 Tage, um eine Schwachstelle nach Erscheinen des Patches auszunutzen. Googles Mandiant-Team misst das jedes Jahr. 2021 und 2022 waren es 32 Tage. 2023 waren es 5 Tage. Für 2024 lag die Zahl bei minus 1, und die Schätzung für 2025 liegt bei minus 7.

Eine negative Zahl bedeutet, dass der durchschnittliche Angriff beginnt, bevor der Patch überhaupt existiert.

Der Großteil dieses Rückgangs geschah, bevor KI in der Sicherheit viel beigetragen hat. Nun kommt KI dazu.

Beide genannten Zahlen betreffen die Verteidigungsseite, mit einem Disclosure-Prozess und Zeit für die Hersteller. Aber eine solche Fähigkeit bleibt nicht auf einer Seite. Ich denke, wir sollten auf eine Welt planen, in der ein automatischer Scanner an fast jedem Tag für wenig Geld eine unbekannte Lücke in nahezu jedem System finden kann.

Nun ein Blick darauf, wie wir uns verteidigen. Jemand meldet die Lücke. Jemand schreibt den Fix. Jemand prüft ihn, testet ihn und stellt ihn bereit. In jedem Schritt sitzt ein Mensch, und die ganze Schleife dauert im guten Fall Tage. Wenn der Angriff Stunden dauert, bleibt der Ingenieur keine Zeit zum Reagieren. Es spielt keine Rolle, wie gut der Ingenieur ist.

Deshalb habe ich eine andere Frage gestellt: Welche Art von Verteidigung braucht keine Zeit zum Reagieren?

Sie muss funktionieren, ohne den Angriff zu kennen, denn der Angriff ist neu. Sie muss ohne einen Menschen funktionieren, denn kein Mensch ist schnell genug. Ich sehe ein Design, das beides erfüllt: überhaupt nicht nach schlechten Dingen suchen. Wissen, was das System tut, wenn es korrekt arbeitet, und alles andere in dem Moment stoppen, in dem es geschieht.

Ich kann das nicht für ein Betriebssystem oder einen Browser bauen. Ich kann es für die Schicht versuchen, die ich selbst schreibe: die API. Das Ergebnis ist BehaviorLock, eine kleine Open-Source-Bibliothek für ASP.NET Core.

Ein API-Endpunkt ist eine langweilige Sache, und das ist seine Stärke. Ein Endpunkt, der eine Bestellung zurückgibt, führt ein SELECT auf einer Tabelle aus. Das tat er gestern, und das wird er morgen tun. Er hat keinen Grund, jemals die Tabelle Users zu lesen, und keinen Grund, einen Host aufzurufen, den er nie aufgerufen hat.

BehaviorLock schreibt also auf, was jeder Endpunkt berührt, und blockiert den Rest. „Erprobt“ hat hier eine einfache Bedeutung: Ein Test hat eine legitime Anfrage gesendet, und dies ist das, was der Endpunkt tat.

{ "GET /orders/{id:int}": [ "sql: SELECT \"o\".\"Id\", \"o\".\"Total\", \"o\".\"UserId\" FROM \"Orders\" AS \"o\" WHERE \"o\".\"Id\" =? LIMIT?" ], "GET /products/search": [ "sql: SELECT * FROM Products WHERE Name LIKE?" ], "POST /orders": [ "http: POST https://payments.example.com", "sql: INSERT INTO \"Orders\" (\"Total\", \"UserId\") VALUES (?) RETURNING \"Id\"" ] } Enter fullscreen mode Exit fullscreen mode Ein sql-Eintrag ist die Form eines Statements: der SQL-Text, bei dem jeder Wert durch? ersetzt wurde. Ein http-Eintrag ist Methode, Scheme, Host und Port eines ausgehenden Aufrufs.

Der Schutz hat keine Liste von Angriffen. Er kann nicht veraltet sein, denn er hat nichts zu aktualisieren. Eine neue Angriffstechnik wird auch an ihrem ersten Tag blockiert, sofern sie einen Endpunkt etwas Neues berühren lässt.

Es ist ein MVP. Es zielt auf.NET 11 und deckt EF Core und IHttpClientFactory ab. Die Einrichtung besteht aus drei Aufrufen:

builder. Services. AddBehaviorLock ( options => builder. Configuration. GetSection ( "BehaviorLock" ). Bind ( options ) ); builder. Services. AddDbContext < ShopDb > ( ( services, options ) => options. UseSqlite ( connectionString ). UseBehaviorLock ( services ) ); app. UseBehaviorLock ( ); Enter fullscreen mode Exit fullscreen mode Das Repository enthält eine kleine Shop-API mit absichtlich eingebauten Schwachstellen. Die Tests führen jeden Angriff zweimal aus: mit ausgeschaltetem Schutz, um den Schaden zu belegen, und im Enforce-Modus, um zu belegen, dass er gestoppt wird.

Zehn Zeilen, und für keine davon hat der Schutz eine Regel. Zwei Zeilen zeigen den Punkt am besten.

Der Debug-Schalter. Jemand hat ein?debug=true im Bestell-Endpunkt hinterlassen, und es liefert jeden Benutzer mit seinem Passwort zurück. In dieser Anfrage ist nichts Schlechtes. Kein Anführungszeichen, kein Payload, nichts, woran eine Signatur matchen könnte. Der Schutz schaut nicht auf die Anfrage. Er sieht, dass ein Endpunkt, der Orders liest, jetzt Users lesen will:

BehaviorLock violation (blocked): endpoint 'GET /orders/{id:int}' attempted 'sql: SELECT "u"."Id", "u"."DisplayName", "u"."Email", "u"."IsAdmin", "u"."Password" FROM "Users" AS "u"' Enter fullscreen mode Exit fullscreen mode Die Abhängigkeit. Der Zahlungs-Client im Beispiel steht für ein Paket, das übernommen wurde. Er funktioniert wie erwartet, kopiert aber jede Bestellung über 1000 zu einem anderen Host. Die Tests legen eine Bestellung über 120 an, sodass kein Test diesen Code jemals ausführen sieht. Das ist das Nächste zu einem Zero-Day auf dieser Schicht: schlechter Code in etwas, dem man vertraut, auf einem Pfad, den niemand angesehen hat. In Produktion versucht die erste große Bestellung, einen Host aufzurufen, der nicht im Profil steht. Der Aufruf verlässt den Server nie.

Die Kosten sind gering. Auf einer lokalen SQLite-Datei, dem schlechtesten Fall für den Schutz, verliert eine EF-Core-Query etwa 2 bis 3 Prozent Durchsatz. Latenz-Perzentile unterscheiden sich um 0,04 ms oder weniger. Eine blockierte Injection ist etwa 2 Prozent schneller als dieselbe API ohne Schutz, weil das Blockieren des Angriffs weniger kostet als seine Ausführung.

Für das Blockieren braucht es keinen Menschen. Das war das Ziel.

Das Lernen neuen legitimen Verhaltens braucht dagegen einen Menschen, und das ist Absicht. Tests decken nie jeden legalen Pfad ab, deshalb ist der Standardmodus Audit: melden, aber erlauben. Der Schutz schreibt jeden unbekannten Zugriff in eine Pending-Datei. Ein Mensch liest sie und entscheidet: Das ist ein legaler Pfad, den die Tests verpasst haben, oder das ist ein Angriff. Legale Pfade bekommen einen Test und wandern ins Profil. Bleibt die Pending-Datei leer, wechselt der Endpunkt in den Enforce-Modus.

Könnte der Schutz neues Verhalten selbst freigeben, würde ein Angreifer es ihm beibringen. Die menschliche Arbeit ist also nicht verschwunden. Sie hat sich verschoben. Sie geschieht jetzt vor dem Angriff, in einem Pull Request, in dem der Profil-Diff zeigt, dass ein Endpunkt etwas Neues berührt. Und sie geschieht nach dem Angriff, in einer Überprüfung dessen, was blockiert wurde. Sie geschieht nicht während des Angriffs, wenn keine Zeit ist.

Eine Welt, in der Scanner überall Lücken finden, schließt die Lücke in meinem eigenen Schutz mit ein. Ich hatte eine in der ersten Version.

Um WHERE Name = 'alice' in WHERE Name =? zu verwandeln, muss der Schutz das Ende des Strings an derselben Stelle finden wie die Datenbank. Die erste Version nutzte die Regel des Standard-SQL. MySQL interpretiert standardmäßig einen Backslash als Escape. Also nehme man eine Query, die aus zwei Formularfeldern gebaut wird, sende einen Backslash als Namen und OR 1=1 -- als Stadt:

SELECT Name FROM Users WHERE Name = '\' AND City = ' OR 1 = 1 -- ' Enter fullscreen mode Exit fullscreen mode Der Schutz sah zwei Strings und die legale Form WHERE Name =? AND City =?. MySQL sah einen String, '\' AND City = ', dann OR 1=1, und lieferte jede Zeile zurück. Der Angreifer brauchte kein einziges Anführungszeichen.

Eine Backslash-Regel behebt das nicht, denn MySQL und PostgreSQL können dieses Escape per Server-Einstellung ein- und ausschalten, und der Schutz kann die Einstellung nicht sehen. Deshalb liest der Schutz jetzt jeden String auf beide Arten. Enden die beiden Lesarten an unterschiedlichen Stellen, normalisiert er das Kommando nicht. Er behält den gesamten Text, der dann nur auf exakt denselben Text im Profil passen kann.

Ich wollte meinem eigenen Lesen der Handbücher nicht erneut vertrauen, deshalb enthält das Repository einen Test, bei dem die Datenbank der Richter ist. Er baut Kommandos aus zufälligen Teilen, führt jedes auf einem echten Server aus und zählt die Zeilen. Ein Kommando, das jede Zeile zurückgibt, hat injizierten Code ausgeführt, also muss seine Form von der legalen Form abweichen.

58 von 8.334 sind 0,7 Prozent. Das klingt klein. Ein Zufallstest probiert blind. Ein Angreifer mit einem guten Modell braucht eines der 58 und wird es finden.

Das ersetzt also keine Parameter, Autorisierungsprüfungen oder Patches. Es ist eine Schicht für die Stunden, in denen all das zu spät kommt.

Ich weiß nicht, ob die Welt des ersten Abschnitts in einem Jahr oder in fünf anbricht. Ich glaube aber, dass „finden, melden, patchen, ausrollen“ gegen einen Scanner verlieren wird, der eine Stunde braucht. Etwas muss im Anfragepfad stehen, das keinen Menschen und kein Update braucht.

BehaviorLock ist mein Versuch für ein Stück davon. Der Code liegt auf github.com/valbarov/BehaviorLock, unter Apache-2.0. Wenn Sie eine Anfrage finden, die einen Endpunkt etwas Neues tun lässt und trotzdem durchgeht, eröffnen Sie bitte ein Issue. Das ist der Bug, von dem ich am meisten hören möchte.

Wenn ein Scanner heute Nacht eine Lücke in Ihrer API fände, was würde die Anfrage stoppen, bevor jemand in Ihrem Team wach ist?

Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.

Original (Englisch) anzeigen

Facts in the opening, and how far each was checked on 2026-11-19:

Everything about the repo is from v1 and was checked there: 197 tests passed and 2 skipped, the real-server tests passed, 80,000 / 8,334 / 58 / 0 from articles/behaviorlock/v1compare, the log line and status codes from the sample API in Enforce mode. Performance numbers are copied from the README and were not run again.

In 2018 and 2019, attackers needed 63 days on average to exploit a vulnerability after its patch came out. Google's Mandiant team measures this every year. In 2021 and 2022 it was 32 days. In 2023 it was 5 days. For 2024 the number was minus 1, and the estimate for 2025 is minus 7.

A negative number means that the average attack starts before the patch exists.

Most of that drop happened before AI did much in security. Now add AI.

Both of these are the defending side, with a disclosure process and time for the vendors. But a skill like this does not stay on one side. I think we should plan for a world where an automatic scanner can find an unknown hole in almost any system, on any day, for little money.

Now look at how we defend. Someone reports the hole. Someone writes the fix. Someone reviews it, tests it and deploys it. There is a person in every step, and the whole loop takes days when it goes well. When the attack takes hours, the engineer has no time to react. It does not matter how good the engineer is.

So I asked another question. What kind of defense needs no time to react?

It must work without knowing the attack, because the attack is new. It must work without a person, because no person is fast enough. I see one design that fits both: do not look for bad things at all. Know what the system does when it works correctly, and stop everything else at the moment it happens.

I cannot build that for an operating system or a browser. I can try it for the layer that I write myself: the API. The result is BehaviorLock, a small open source library for ASP.NET Core.

An API endpoint is a boring thing, and that is its strength. An endpoint that returns one order runs one SELECT on one table. It did that yesterday and it will do that tomorrow. It has no reason to ever read the Users table, and no reason to call a host it has never called.

So BehaviorLock writes down what each endpoint touches, and blocks the rest. "Proven" has a simple meaning here: a test sent a legal request, and this is what the endpoint did.

{ "GET /orders/{id:int}": [ "sql: SELECT \"o\".\"Id\", \"o\".\"Total\", \"o\".\"UserId\" FROM \"Orders\" AS \"o\" WHERE \"o\".\"Id\" =? LIMIT?" ], "GET /products/search": [ "sql: SELECT * FROM Products WHERE Name LIKE?" ], "POST /orders": [ "http: POST https://payments.example.com", "sql: INSERT INTO \"Orders\" (\"Total\", \"UserId\") VALUES (?) RETURNING \"Id\"" ] } Enter fullscreen mode Exit fullscreen mode A sql entry is the shape of a statement: the SQL text with every value replaced by?. An http entry is the method, scheme, host and port of an outbound call.

The guard has no list of attacks. It cannot be out of date, because it has nothing to update. A new attack technique is still blocked on its first day, as long as it makes an endpoint touch something new.

It is an MVP. It targets.NET 11 and covers EF Core and IHttpClientFactory. The setup is three calls:

builder. Services. AddBehaviorLock ( options => builder. Configuration. GetSection ( "BehaviorLock" ). Bind ( options ) ); builder. Services. AddDbContext < ShopDb > ( ( services, options ) => options. UseSqlite ( connectionString ). UseBehaviorLock ( services ) ); app. UseBehaviorLock ( ); Enter fullscreen mode Exit fullscreen mode The repo has a small shop API with weaknesses built in on purpose. The tests run each attack twice: with the guard off, to prove the harm is real, and in Enforce mode, to prove it is stopped.

Ten rows, and the guard has no rule for any of them. Two rows show the point best.

The debug switch. Someone left a?debug=true in the order endpoint, and it returns every user with their password. There is nothing bad in that request. No quote, no payload, nothing a signature could match. The guard does not look at the request. It sees that an endpoint which reads Orders now wants to read Users:

BehaviorLock violation (blocked): endpoint 'GET /orders/{id:int}' attempted 'sql: SELECT "u"."Id", "u"."DisplayName", "u"."Email", "u"."IsAdmin", "u"."Password" FROM "Users" AS "u"' Enter fullscreen mode Exit fullscreen mode The dependency. The payment client in the sample stands for a package that was taken over. It works as expected, but it copies every order above 1000 to another host. The tests place an order of 120, so no test ever sees that code run. This is the closest thing to a zero-day at this layer: bad code inside something you trust, on a path that nobody has looked at. In production the first large order tries to call a host that is not in the profile. The call never leaves the server.

The cost is small. On a local SQLite file, which is the worst case for the guard, one EF Core query loses about 2% to 3% of throughput. Latency percentiles differ by 0.04 ms or less. A blocked injection is about 2% faster than the same API without the guard, because blocking the attack costs less than running it.

The blocking needs no person. That was the goal.

Learning new legal behavior does need a person, and that is on purpose. Tests never cover every legal path, so the default mode is Audit: report, but allow. The guard writes each unknown access to a pending file. A person reads it and decides: this is a legal path that the tests missed, or this is an attack. Legal paths get a test and move into the profile. When the pending file stays empty, the endpoint goes to Enforce.

If the guard could approve new behavior by itself, an attacker would teach it. So the human work did not go away. It moved. It now happens before the attack, in a pull request where the profile diff shows that an endpoint touches something new. And it happens after the attack, in a review of what was blocked. It does not happen during the attack, when there is no time.

A world where scanners find holes everywhere includes the hole in my guard. I had one in the first version.

To turn WHERE Name = 'alice' into WHERE Name =?, the guard must find the end of the string at the same place as the database. The first version used the rule of standard SQL. MySQL, by default, reads a backslash as an escape. So take a query that is built from two form fields, send one backslash as the name, and send OR 1=1 -- as the city:

SELECT Name FROM Users WHERE Name = '\' AND City = ' OR 1 = 1 -- ' Enter fullscreen mode Exit fullscreen mode The guard saw two strings and the legal shape, WHERE Name =? AND City =?. MySQL saw one string, '\' AND City = ', then OR 1=1, and returned every row. The attacker did not need a single quote character.

A backslash rule does not fix it, because MySQL and PostgreSQL can turn that escape on and off with a server setting, and the guard cannot see the setting. So the guard now reads each string both ways. When the two readings end at different places, it does not normalize the command. It keeps the whole text, which can then only match the exact same text in the profile.

I did not want to trust my own reading of the manuals again, so the repo has a test where the database is the judge. It builds commands from random pieces, runs each one on a real server, and counts the rows. A command that returns every row ran injected code, so its shape must differ from the legal shape.

58 of 8,334 is 0.7%. It looks small. A random test tries things blind. An attacker with a good model needs one of the 58, and will find it.

So this does not replace parameters, authorization checks or patching. It is a layer for the hours when all of those are late.

I do not know if the world of the first section arrives in one year or in five. I do think that "find, report, patch, deploy" will lose to a scanner that needs an hour. Something has to stand in the request path that needs no person and no update.

BehaviorLock is my attempt at one piece of that. The code is at github.com/valbarov/BehaviorLock, under Apache-2.0. If you find a request that makes an endpoint do something new and still passes, please open an issue. That is the bug I most want to hear about.

If a scanner found a hole in your API tonight, what would stop the request before anyone on your team is awake?

Originaltitel: AI Finds Holes Faster Than We Can Patch Them. So My API Blocks Everything It Has Not Done BeforeQuelle: dev.to (dev.to). Original öffnen