-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update main.java #1
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ class Connector1 { | |
@javax.jws.WebMethod | ||
void connect(HttpServletRequest req){ | ||
HttpServletResponse res = new HttpServletResponse(); | ||
res.setHeader("Access-Control-Allow-Origin", "*"); | ||
res.setHeader("Access-Control-Allow-Origin", "*"); | ||
} | ||
} | ||
|
||
|
@@ -20,7 +20,7 @@ public class HttpRequestDebugFilter implements Filter { | |
public void doFilter(ServletRequest request) throws IOException, | ||
ServletException { | ||
if (request instanceof HttpServletRequest) { | ||
javax.crypto.Cipher.getInstance("/CBC/PKCS5Padding") | ||
javax.crypto.Cipher.getInstance("/CBC/PKCS5Padding" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use of a broken or risky cryptographic algorithm
|
||
} | ||
} | ||
} | ||
|
@@ -30,7 +30,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.csrf().ignoringAntMatchers("/route/fre"); | ||
http.csrf().ignoringAntMatchers("/route/fre" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CSRF is Disabled
|
||
} | ||
} | ||
|
||
|
@@ -43,57 +43,57 @@ void connect(HttpServletRequest req){ | |
|
||
class Connector3 { | ||
void connect(HttpServletRequest req){ | ||
javax.servlet.http.Cookie cookie = new Cookie("cookie") | ||
javax.servlet.http.Cookie cookie = new Cookie("cookie" ) | ||
HttpServletResponse res = new HttpServletResponse(); | ||
res.addCookie(cookie); | ||
res.addCookie(cookie ); | ||
} | ||
} | ||
|
||
class Connector4 { | ||
@javax.jws.WebMethod | ||
void connect(HttpServletRequest req){ | ||
javax.crypto.Cipher.getInstance("DES/CBC/NoPadding"); | ||
javax.crypto.Cipher.getInstance("DES/CBC/NoPadding" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsafe DES algorithm used
|
||
} | ||
} | ||
|
||
class Connector5 { | ||
@javax.jws.WebMethod | ||
void connect(HttpServletRequest req){ | ||
Keygen keygen = javax.crypto.KeyGenerator.getInstance("Blowfish"); | ||
keygen.init(100); | ||
Keygen keygen = javax.crypto.KeyGenerator.getInstance("Blowfish" ); | ||
keygen.init(100 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Encryption keys with less than 128 bits
|
||
} | ||
} | ||
|
||
class Connector6 { | ||
@javax.jws.WebMethod | ||
void connect(HttpServletRequest req){ | ||
javax.servlet.http.Cookie cook = new Cookie("cookie"); | ||
cook.setSecure(false); | ||
req.addCookie(cook); | ||
javax.servlet.http.Cookie cook = new Cookie("cookie" ); | ||
cook.setSecure(false ); | ||
req.addCookie(cook ); | ||
} | ||
} | ||
|
||
|
||
class Connector7 { | ||
@javax.jws.WebMethod | ||
void connect(HttpServletRequest req){ | ||
Cookie cook = new Cookie("cookie"); | ||
cook.setMaxAge(31536000); | ||
Cookie cook = new Cookie("cookie" ); | ||
cook.setMaxAge(31536000 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cookie stored for an extended period of time
|
||
} | ||
} | ||
|
||
class Connector8 { | ||
void connect(HttpServletRequest req){ | ||
java.nio.file.Files.createTempDirectory("file"); | ||
java.nio.file.Files.createTempDirectory("file" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File Creation in Publicly Shared Directories
|
||
} | ||
} | ||
|
||
public class WeakNightVoter implements AccessDecisionVoter { | ||
@Override | ||
public int vote(Authentication authentication, Object object, Collection collection) { // Noncompliant | ||
Calendar calendar = Calendar.getInstance(); | ||
public int vote(Authentication authentication, Object object, Collection collection) { //Noncompliant | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Authorization is not robust
|
||
Calendar calendar = Calendar.getInstance( ); | ||
int currentHour = calendar.get(Calendar.HOUR_OF_DAY); | ||
return ACCESS_ABSTAIN; // Noncompliant | ||
return ACCESS_ABSTAIN; //Noncompliant | ||
} | ||
} | ||
|
||
|
@@ -102,15 +102,15 @@ class Connector9 { | |
void connect(HttpServletRequest req){ | ||
Cookie cook = new Cookie("cookie"); | ||
for (Cookie cookie : req.getCookies()) { | ||
cookie.getPath(); | ||
cookie.getPath( ); | ||
} | ||
} | ||
} | ||
|
||
class Connector10 { | ||
@javax.jws.WebMethod | ||
void connect(HttpServletRequest req){ | ||
Cookie cook = new Cookie("cookie"); | ||
Cookie cook = new Cookie("cookie" ); | ||
req.setAttribute(cook.getString(), cook.getVal()); | ||
} | ||
} | ||
|
@@ -126,7 +126,7 @@ public class Decorator2 { | |
|
||
public void decorator(HttpServletRequest request) { | ||
ServletFileUpload sfu = new ServletFileUpload(); | ||
FileItem[] files = sfu.parseRequest(request); | ||
FileItem[] files = sfu.parseRequest(request ); | ||
for (FileItem file : files) { | ||
System.out.println(file.getName()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integrity of the data during transmission is not being verified
File: main.java | Checkov ID: CKV3_SAST_12
Description
CWE:
CWE-353: Missing Support for Integrity Check
OWASP:
A08:2021 - Software and Data Integrity Failures
This violation is indicating that the cipher being used for encryption does not provide an integrity check to validate that the encrypted data has not been tampered with. Specifically, it flags the use of AES and DES (or triple DES) in ECB (Electronic Codebook) mode and the use of CBC (Cipher Block Chaining) mode with PKCS5 padding, which do not inherently provide integrity checks.
When these ciphers are used without an additional mechanism to ensure the integrity of the data, it makes the encrypted data susceptible to alterations by an adversary without detection, presenting a security concern.
Example violating code:
In the example above, AES encryption with CBC mode and PKCS5Padding is being used, which doesn't provide an integrity check on the encrypted data.