Blog

How secure coding guidelines evolve

September 15, 2017
Pieter De Cremer
World map showing hacktivists from Italy, USA, and Brazil attacking the Code Snippets application in Europe.

Last week I was researching vulnerabilities in Java Spring to bring our secure coding guidelines up to date. I was going through the existing challenges on our platform and noticed a few on XSS through displaying url parameters in JSP pages. The incorrect code example would look something similar to the following:

   <input type="text" name="username" value="${param.username}">

The correct solution was removing the URL parameter altogether and the description mentions that escaping the URL parameter the correct way is also safe.

Now, my job is to formulate the secure coding guideline in a way that is clear to developers and restricts them as little as possible while still writing secure code. In this case, I would prefer to let developers keep their intended functionality and recommend them to do it securely by escaping the URL parameter. This way, the code no longer contains a XSS vulnerability. The above example can be secured like this:

   <input type="text" name="username" value="${fn:escapeXml(param.username)}">

And this was our secure coding guideline for a few days, until I stumbled on an OWASP page on expression language injection. This page describes how the Spring Expression Language (SpEL) can be abused for injection with some serious impact, including remote code execution. It was up to me to figure out if there could be cases where code adhering to our secure coding guideline can still be affected by this vulnerability. So I wrote a quick test application to evaluate SpEL expressions, and tested input with and without Xml escaping to see if I could find some scenarios that would not be caught. And I did, there are malicious expressions that do not contain any characters caught by XmlEscape. I published the working demo on our github, which you can find here.

And of course I updated our secure coding guideline which now reads: "Do not display or evaluate URL parameters using the Spring Expression Language (SpEL)."

The overall impact of this issue is High, for the following reasons:  - An attacker could modify and invoke functionality on the application server. - Unauthorized access to data and functionality, as well as account hijacking and remote code execution. - Confidentiality, and Integrity concerns from a successful attack.

https://www.owasp.org/index.php/Expression_Language_Injection

Govern AI-driven development before it ships

Measure AI-assisted risk, enforce secure coding policy at commit, and accelerate secure delivery across your SDLC.

Book a demo
Resource library

Explore more blogs

Access expert content on secure coding, AI governance, and software risk management.

browse all
Blog
Filter Label
This is some text inside of a div block.

Enabler 10: Training Linked to Career Progression

Training only gets prioritized when it carries real career value. Enabler 10 shows how tying secure coding to performance goals drives lasting participation.

Learn More
Blog
Filter Label
This is some text inside of a div block.

If the model is the smallest security lever, what actually makes AI-generated code safer?

Earlier this year, we released the SCW AI Trust Index, and, in conjunction with RMIT University, assessed 16 leading AI models from OpenAI, Anthropic, Google, and others, generating 1760 codebases and finding 15 vulnerabilities on average in each one. This data, using our original methodology, allowed us to ultimately identify that security risk is predictable by model and framework. 

‍

Learn More
Blog
Filter Label
This is some text inside of a div block.

Run your secure coding program from your AI tool

Track training progress, draft Quests, and report on your SCW secure coding program from any MCP-compatible AI tool. Included with every SCW plan.

Learn More

Secure AI-driven development before it ships

See developer risk, enforce policy, and prevent vulnerabilities across your software development lifecycle.

Book a demo
trust score
No items found.