SCW Icons
hero bg no divider
Blog

Wie sich die Richtlinien für sichere Codierung entwickeln

Pieter De Cremer
Published Sep 15, 2017
Last updated on Mar 09, 2026

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

Ressource ansehen
Ressource ansehen

Letzte Woche habe ich nach Sicherheitslücken in Java Spring gesucht, um unsere Richtlinien für sicheres Codieren auf den neuesten Stand zu bringen.

Interessiert an mehr?

Forscher für Anwendungssicherheit - Forschungs- und Entwicklungsingenieur - Doktorand

learn more

Secure Code Warrior ist für Ihr Unternehmen da, um Ihnen zu helfen, Code während des gesamten Softwareentwicklungszyklus zu sichern und eine Kultur zu schaffen, in der Cybersicherheit an erster Stelle steht. Ganz gleich, ob Sie AppSec-Manager, Entwickler, CISO oder jemand anderes sind, der sich mit Sicherheit befasst, wir können Ihrem Unternehmen helfen, die mit unsicherem Code verbundenen Risiken zu reduzieren.

Eine Demo buchen
Teilen auf:
linkedin brandsSocialx logo
Autor
Pieter De Cremer
Published Sep 15, 2017

Forscher für Anwendungssicherheit - Forschungs- und Entwicklungsingenieur - Doktorand

Teilen auf:
linkedin brandsSocialx logo

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

Ressource ansehen
Ressource ansehen

Füllen Sie das unten stehende Formular aus, um den Bericht herunterzuladen

Wir bitten um Ihre Erlaubnis, Ihnen Informationen zu unseren Produkten und/oder verwandten Themen rund um sichere Codierung zuzusenden. Wir behandeln Ihre persönlichen Daten stets mit größter Sorgfalt und verkaufen sie niemals zu Marketingzwecken an andere Unternehmen.

Einreichen
scw success icon
scw error icon
Um das Formular abzusenden, aktivieren Sie bitte „Analytics“ -Cookies. Wenn Sie fertig sind, können Sie sie jederzeit wieder deaktivieren.

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

Webinar ansehen
Fangen Sie an
learn more

Klicken Sie auf den Link unten und laden Sie das PDF dieser Ressource herunter.

Secure Code Warrior ist für Ihr Unternehmen da, um Ihnen zu helfen, Code während des gesamten Softwareentwicklungszyklus zu sichern und eine Kultur zu schaffen, in der Cybersicherheit an erster Stelle steht. Ganz gleich, ob Sie AppSec-Manager, Entwickler, CISO oder jemand anderes sind, der sich mit Sicherheit befasst, wir können Ihrem Unternehmen helfen, die mit unsicherem Code verbundenen Risiken zu reduzieren.

Bericht ansehenEine Demo buchen
Ressource ansehen
Teilen auf:
linkedin brandsSocialx logo
Interessiert an mehr?

Teilen auf:
linkedin brandsSocialx logo
Autor
Pieter De Cremer
Published Sep 15, 2017

Forscher für Anwendungssicherheit - Forschungs- und Entwicklungsingenieur - Doktorand

Teilen auf:
linkedin brandsSocialx logo

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

Inhaltsverzeichniss

PDF herunterladen
Ressource ansehen
Interessiert an mehr?

Forscher für Anwendungssicherheit - Forschungs- und Entwicklungsingenieur - Doktorand

learn more

Secure Code Warrior ist für Ihr Unternehmen da, um Ihnen zu helfen, Code während des gesamten Softwareentwicklungszyklus zu sichern und eine Kultur zu schaffen, in der Cybersicherheit an erster Stelle steht. Ganz gleich, ob Sie AppSec-Manager, Entwickler, CISO oder jemand anderes sind, der sich mit Sicherheit befasst, wir können Ihrem Unternehmen helfen, die mit unsicherem Code verbundenen Risiken zu reduzieren.

Eine Demo buchenHerunterladen
Teilen auf:
linkedin brandsSocialx logo
Ressourcen-Hub

Ressourcen für den Einstieg

Mehr Beiträge
Ressourcen-Hub

Ressourcen für den Einstieg

Mehr Beiträge