loading experience
Design · Secure by Design

AST — Secure by Design & AI Cybersecurity: why security begins with code, not infrastructure

Security is built into the foundation.

A WAF protects the perimeter but cannot repair a structural flaw. Vulnerabilities must be eliminated in the code, and today even the AI that writes it can verify and correct it by itself.

Scroll to explore
01 · The skyscraper analogy

Code as the foundation, infrastructure as the frame

If a skyscraper is built on unstable sand, it does not matter how thick the outer walls are, how many automatic gates guard the perimeter or how advanced the cameras are: the building remains vulnerable to internal structural failure.

02 · Concrete examples

Where infrastructure fails without secure code

SQL Injection (SQLi)
What the WAF sees

A standard HTTP request. Obfuscated payloads or double-encoding can bypass WAF signature rules.

Why it is fixed in code

With parameterized queries or an ORM, user input can never be interpreted as a SQL command.

var sql = "SELECT * FROM users WHERE name = '" + name + "'";   // ✗
cmd.CommandText = "SELECT * FROM users WHERE name = @name";
cmd.Parameters.AddWithValue("@name", name);                    // ✓
Broken Object Level Authorization (BOLA)
What the WAF sees

A valid GET /api/v1/orders/99482 with a valid JWT: network rules cannot determine order ownership.

Why it is fixed in code

Only code-level authorization checks can verify that the user owns the resource before returning data.

var order = await db.Orders.FindAsync(id);
return Ok(order);                                              // ✗
var order = await db.Orders.FindAsync(id);
if (order?.OwnerId != currentUserId) return Forbid();
return Ok(order);                                              // ✓
Server-Side Request Forgery (SSRF)
What the WAF sees

The app server making an outbound HTTPS call: allowed by egress firewall policies.

Why it is fixed in code

Unless code validates and restricts user-supplied URLs, attackers can make the server query internal metadata APIs (e.g. AWS IMDSv1).

var body = await http.GetStringAsync(url);                     // ✗
if (!Uri.TryCreate(url, UriKind.Absolute, out var u)
    || u.Scheme != "https" || !allowedHosts.Contains(u.Host))
    return BadRequest();                                       // ✓
03 · The 2018 origin story

From AST engines to native Secure by Design

The vision of code-first cybersecurity originated in 2018, driven by the realization that reactive security (finding bugs late via VAPT or DAST in staging or production) was both inefficient and cost-prohibitive.

  1. CodeAST · taint · Quality Gate
  2. Build / CISAST
  3. StagingDAST
  4. ProductionVAPT · WAF

shift left · the earlier a defect is found, the cheaper it is to fix

AST

Abstract Syntax Tree

By leveraging Abstract Syntax Tree engine prototypes, code security shifted left:

  1. Syntactic parsing source code becomes a tree representing the exact grammar and semantics of the program.
  2. Data-flow & taint analysis untrusted inputs are tracked from entry points (Sources) to sensitive execution blocks (Sinks).
  3. Immediate validation antipatterns (hardcoded secrets, weak cryptography, race conditions) are caught while writing code, before compilation and deployment.
Taint analysis

Source → Sink

If a path exists from Source to Sink without passing through a sanitizer, the engine flags the vulnerability and the exact location.

04 · QualityGuard

AI that self-verifies and self-corrects its own code

The rise of generative AI and LLM coding assistants introduced a new challenge: high-velocity code generation that frequently introduces subtle security vulnerabilities. To solve it, QualityGuard was created.

AI AgentClaude / LLM
QualityGuardAST Engine · MCP Server
MCP · Model Context Protocol

A stateless, in-memory engine

QualityGuard is a stateless, in-memory code quality engine and Quality Gate evaluator engineered to integrate directly with AI agents via the Model Context Protocol (MCP).

27languages
4,095rules
665security rules

From the README: written in C#, it runs on real syntax trees with a semantic model, project index and interprocedural taint analysis. No background service, database or UI. The MCP server exposes scans, gate state and AI-formatted Markdown reports over stdio or Streamable HTTP.

Closed-loop

How AI uses it while coding

  1. In-memory scanning as the AI writes or modifies code, it calls the QualityGuard MCP server.
  2. AST analysis across 27 languages code is parsed in memory, evaluating security rules, cyclomatic complexity and quality metrics.
  3. Closed-loop feedback if the Quality Gate fails (unvalidated input, OWASP rule breach), an AI-optimized Markdown report returns with the precise file location and defect.
  4. Autonomous self-correction the agent reads the report, understands the vulnerability and refactors the code before committing or opening a Pull Request.
DigitalSolutions

Security isn't added on: it's written in.

Explore QualityGuard on GitHub or see it at work inside Kodinn.