DaloyJS Secures Backends in the Era of AI-Generated Code

DaloyJS Secures Backends in the Era of AI-Generated Code

With a decade of full-stack development experience stretching from the Philippines to the dimly lit winters of Norway, Vijay Raina has seen the backend landscape shift from hand-rolled scripts to AI-orchestrated microservices. As a specialist in enterprise SaaS technology and software architecture, he has developed a reputation for his “grumpy” but essential focus on the boring, often-overlooked vulnerabilities that cause the most damage in production. His work centers on the philosophy that security should not be a checklist added at the end of a project, but a series of rigid, safe defaults that prevent a system from even booting if it is misconfigured. In an era where AI agents can generate a functional API in seconds, his expertise lies in ensuring those “200 OK” responses do not hide catastrophic architectural flaws.

This discussion explores the dangerous gap between a functional backend and a secure one, particularly when code is generated by AI agents that lack a developer’s natural intuition for risk. We delve into the “trap” of modern framework defaults—such as unbounded JSON bodies, wildcard CORS configurations, and naive fetch calls—that lead to denial-of-service attacks and server-side request forgery. The conversation highlights the “secure-by-default” architecture of DaloyJS, illustrating how a framework can enforce 64 KB body limits, mandate 32-byte secrets, and provide guarded fetch utilities to neutralize SSRF. We also address the evolving threats in the software supply chain, including “slopsquatting” and the necessity of enforcing a 24-hour “cooldown” period for new package versions to ensure stability and safety.

How has the rise of AI-generated code changed the fundamental nature of backend security risks, and why is a “functional” response no longer a sufficient metric for success?

The shift we are seeing is that backend security incidents are becoming increasingly boring and predictable, yet more frequent because the code is no longer being typed by humans who feel a sense of dread when they see a wildcard. For the last ten years, I have watched developers transition from manual coding to using agents that can install forty dependencies and open a PR within the hour, but the problem is that these agents only care about the “happy path.” If an AI describes an app and it returns a 200 OK status code, the agent and the developer both assume the job is done, when in reality, the system might be wide open to a denial-of-service attack because someone forgot a body limit. A backend that boots and doesn’t complain isn’t necessarily finished; it’s just a trap waiting to be sprung in production because the agent doesn’t have that small voice in the back of its head questioning why a specific security check was removed just to make a test pass. We have moved into an era where “make it work” and “make it safe” must be the exact same action, because the entity writing the code—whether a human at 2 AM or a tireless model—will always take the path of least resistance.

When looking at standard framework configurations like those found in Express, what are the most common “boring” vulnerabilities that skip past traditional testing suites?

Most of what goes wrong in a modern API is remarkably un-clever and happens because we trust defaults that were designed for convenience rather than defense. For instance, using express.json() without a specific size limit allows an attacker to buffer a multi-megabyte body into memory; if you send a few hundred of those simultaneously, you’ve achieved a denial of service for practically zero cost. Then you have the classic CORS wildcard configuration combined with credentials, which is effectively the digital equivalent of leaving your house keys in the front door for any passing origin to find. We also see the “SSRF speedrun” where a developer—or an AI—writes a simple fetch for a URL provided in the request body without realizing it can be pointed at internal metadata endpoints like 169.254.169.254 to exfiltrate cloud credentials. These flaws don’t fail a unit test because the test posts a book, sees the book is created, and turns green, leaving the vulnerability to ship to production wearing a deceptive little checkmark.

How does the “secure-by-default” philosophy manifest in the startup process of a framework, and why is a “loud startup crash” preferable to a silent vulnerability?

The core of my philosophy is that the framework should refuse to play along if you hand it a configuration that is obviously a foot-gun. In DaloyJS, for example, we have built-in “boot guards” that will throw an error and prevent the server from starting if you try to use a wildcard CORS origin in a production environment or if you provide a session secret that is a well-known placeholder like “changeme.” We even check for entropy; if a secret is just a single repeated character or is below the 32-byte minimum length, the app simply won’t boot and will instead provide an error message suggesting the exact openssl command needed to fix it. This turns what would be an expensive, quiet vulnerability in production into a free, loud crash during the initial development or CI phase, ensuring that “later”—the place where security usually goes to die—never actually happens. By making the framework assume that an insecure configuration is a bug rather than a preference, we force the lazy path and the safe path to point in the same direction.

Outbound HTTP calls are becoming a staple of modern backends, but you’ve warned that they are a major entry point for attackers. How does a guarded fetch mechanism protect against sophisticated SSRF attacks?

Outbound fetches are the most ignored security hole in the current agent era because backends are constantly calling external URLs for everything from summarizing links to webhook subscriptions. A naive fetch(url) is dangerous because an attacker can provide a URL that points inward at your own cloud metadata service, internal admin tools, or a local database that trusts the internal network. To combat this, we utilize a fetchGuard that acts as a drop-in replacement, automatically denying loopback addresses like 127.0.0.0/8, private RFC1918 ranges, and documented cloud metadata IPs for AWS, GCP, Azure, and even Alibaba or Oracle. What makes this really robust is how it handles redirects; a lot of guards only check the first URL, but our utility follows redirects manually and re-validates every single hop against the deny rules to prevent an attacker from using a 302 redirect to bypass the initial check. It even recursively checks IPv4-mapped IPv6 addresses, which is the kind of detail you only get right after you’ve been burned by someone trying to smuggle a blocked address through a different notation.

The “confused deputy” attack on JWTs is a well-known risk in API security. How can backend architecture prevent this without relying on developer vigilance?

The “confused deputy” or algorithm confusion attack is a perfect example of where a framework can intervene to stop a career-ending mistake. This happens when an API is configured to accept both symmetric HS256 and asymmetric RS256 algorithms, allowing an attacker to use a server’s public RSA key to sign a token with HS256, which a naive verifier will then accept. In our architecture, we close this hole by making it impossible to even construct a verifier that allows a symmetric algorithm when you are verifying against a JWKS (JSON Web Key Set). If you try to pass “HS256” into the algorithm allowlist for a JWKS-based verification, the system throws an error immediately before a single request is ever served. We also require a non-empty, explicit algorithm allowlist and enforce issuer and audience checks, ensuring that the verifier applies a prototype-pollution-safe reviver to any attacker-controlled claims within the token.

With the rise of “slopsquatting” and malicious npm packages, how can developers protect their supply chain from being poisoned by the very tools they use to build?

The supply chain is arguably the most frightening vector today because you can be owned by code you installed before you even wrote your first route. We’ve seen everything from self-replicating npm worms to “slopsquatting,” where attackers register package names that AI models are likely to hallucinate and suggest to unsuspecting developers. To mitigate this, our core package has zero runtime dependencies, which eliminates the transitive tree that an attacker could poison in the first place. We also encourage a specific posture through .npmrc settings that ignore post-install scripts and, more importantly, implement a minimum-release-age of 1440 minutes, or 24 hours. This means a package version must be at least a day old to be installed, which is a massive defense because most malicious packages are caught and yanked within hours of being published; trading a day of “newness” for a drastic reduction in the chance of being patient zero is a trade every enterprise should make.

What is your forecast for the future of backend development as AI continues to take over the role of the primary code author?

I believe we are entering a phase where the “smart” engineer will no longer be defined by how they write code, but by how they design the constraints that govern the code written by machines. As agents become more literal-minded and focused on the “make it work” directive, we will see a surge in “logic-based” vulnerabilities—the boring stuff like broken object-level authorization where a user can change an ID in a URL to see someone else’s invoice. My forecast is that frameworks will have to evolve to be even more opinionated, moving beyond just handling requests to becoming rigorous enforcers of state and identity. We won’t get security by trying to be more vigilant than the machine; we will get it by making the safe path the only easy path, ensuring that when the agent takes the shortcut at 3 AM, it lands on a foundation of secure defaults that protect the system even when the developer isn’t looking.

Subscribe to our weekly news digest.

Join now and become a part of our fast-growing community.

Invalid Email Address
Thanks for Subscribing!
We'll be sending you our best soon!
Something went wrong, please try again later