File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed
src/main/java/com/acme/headerinjection Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1212 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
1313 <sonar .host.url>https://sonarcloud.io</sonar .host.url>
1414 <sonar .organization>pixee</sonar .organization>
15- </properties >
15+ <versions .java-security-toolkit>1.2.1</versions .java-security-toolkit>
16+ </properties >
1617
1718 <dependencyManagement >
1819 <dependencies >
3132 <dependency >
3233 <groupId >io.github.pixee</groupId >
3334 <artifactId >java-security-toolkit</artifactId >
34- <version >1.2.0 </version >
35+ <version >${versions.java-security-toolkit} </version >
3536 </dependency >
3637 </dependencies >
3738 </dependencyManagement >
Original file line number Diff line number Diff line change 11package com .acme .headerinjection ;
22
3+ import io .github .pixee .security .Newlines ;
34import jakarta .ws .rs .GET ;
45import jakarta .ws .rs .Path ;
56import jakarta .ws .rs .QueryParam ;
@@ -11,7 +12,7 @@ public class HeaderInjectionVuln {
1112
1213 @ GET
1314 public String lookupResource (HttpServletResponse response , @ QueryParam ("q" ) final String q ) {
14- response .setHeader ("X-Last-Search" , q );
15+ response .setHeader ("X-Last-Search" , Newlines . stripAll ( q ) );
1516 return "ok" ;
1617 }
1718}
Original file line number Diff line number Diff line change 11package com .acme .headerinjection ;
22
3+ import io .github .pixee .security .Newlines ;
34import jakarta .ws .rs .GET ;
45import jakarta .ws .rs .Path ;
56import jakarta .ws .rs .QueryParam ;
@@ -11,7 +12,7 @@ public class HeaderInjectionVulnFixed {
1112
1213 @ GET
1314 public String lookupResource (HttpServletResponse response , @ QueryParam ("q" ) final String q ) {
14- response .setHeader ("X-Last-Search" , stripNewlines (q ));
15+ response .setHeader ("X-Last-Search" , Newlines . stripAll ( stripNewlines (q ) ));
1516 return "ok" ;
1617 }
1718
You can’t perform that action at this time.
0 commit comments