split build and check jobs #482
SpotBugs Source Code Analyzer report
219 violation(s) found
Annotations
Check warning on line 59 in core/src/main/java/com/yubico/yubikit/core/application/CommandState.java
github-actions / SpotBugs
WA_NOT_IN_LOOP
Wait not in loop in com.yubico.yubikit.core.application.CommandState.waitForCancel(long)
Raw output
This method contains a call to java.lang.Object.wait() which is not in a loop. If the monitor is used for multiple conditions, the condition the caller intended to wait for might not be the one that actually occurred.
Check warning on line 49 in core/src/main/java/com/yubico/yubikit/core/fido/FidoProtocol.java
github-actions / SpotBugs
CT_CONSTRUCTOR_THROW
Exception thrown in class com.yubico.yubikit.core.fido.FidoProtocol at new com.yubico.yubikit.core.fido.FidoProtocol(FidoConnection) will leave the constructor. The object under construction remains partially initialized and may be vulnerable to Finalizer attacks.
Raw output
Classes that throw exceptions in their constructors are vulnerable to Finalizer attacks
A finalizer attack can be prevented, by declaring the class final, using an empty finalizer declared as final, or by a clever use of a private constructor.
See SEI CERT Rule OBJ-11 [https://wiki.sei.cmu.edu/confluence/display/java/OBJ11-J.+Be+wary+of+letting+constructors+throw+exceptions] for more information.
Check warning on line 63 in core/src/main/java/com/yubico/yubikit/core/fido/FidoProtocol.java
github-actions / SpotBugs
DMI_RANDOM_USED_ONLY_ONCE
Random object created and used only once in new com.yubico.yubikit.core.fido.FidoProtocol(FidoConnection)
Raw output
This code creates a java.util.Random object, uses it to generate one random number, and then discards the Random object. This produces mediocre quality random numbers and is inefficient. If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number is required invoke a method on the existing Random object to obtain it.
If it is important that the generated Random numbers not be guessable, you must not create a new Random for each random number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead (and avoid allocating a new SecureRandom for each random number needed).
Check warning on line 128 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.trace(Ljava/lang/String;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 131 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.debug(Ljava/lang/String;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 134 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.info(Ljava/lang/String;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 137 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.warn(Ljava/lang/String;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 140 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.error(Ljava/lang/String;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 152 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.trace(Ljava/lang/String;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 155 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.debug(Ljava/lang/String;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 158 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.info(Ljava/lang/String;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 161 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.warn(Ljava/lang/String;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 164 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.error(Ljava/lang/String;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 176 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.trace(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 179 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.debug(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 182 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.info(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 185 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 188 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.error(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 200 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.trace(Ljava/lang/String;[Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 203 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.debug(Ljava/lang/String;[Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 206 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.info(Ljava/lang/String;[Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 209 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.warn(Ljava/lang/String;[Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
Check warning on line 212 in core/src/main/java/com/yubico/yubikit/core/internal/Logger.java
github-actions / SpotBugs
CRLF_INJECTION_LOGS
This use of org/slf4j/Logger.error(Ljava/lang/String;[Ljava/lang/Object;)V might be used to include CRLF characters into log messages
Raw output
When data from an untrusted source is put into a logger and not neutralized correctly, an attacker could forge log entries or include malicious content. Inserted false entries could be used to skew statistics, distract the administrator or even to implicate another party in the commission of a malicious act. If the log file is processed automatically, the attacker can render the file unusable by corrupting the format of the file or injecting unexpected characters. An attacker may also inject code or other commands into the log file and take advantage of a vulnerability in the log processing utility (e.g. command injection or XSS).
Code at risk:
String val = request.getParameter("user");
String metadata = request.getParameter("metadata");
[...]
if(authenticated) {
log.info("User " + val + " (" + metadata + ") was authenticated successfully");
}
else {
log.info("User " + val + " (" + metadata + ") was not authenticated");
}
A malicious user could send the metadata parameter with the value: "Firefox) was authenticated successfully\r\n[INFO] User bbb (Internet Explorer".
Solution:
You can manually sanitize each parameter.
log.info("User " + val.replaceAll("[\r\n]","") + " (" + userAgent.replaceAll("[\r\n]","") + ") was not authenticated");
You can also configure your logger service to replace new line for all message events. Here is sample configuration for LogBack using the replace function [https://logback.qos.ch/manual/layouts.html#replace].
%-5level - %replace(%msg){'[\r\n]', ''}%n
Finally, you can use a logger implementation that replace new line by spaces. The project OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging] has an implementation for Logback and Log4j.
References
CWE-117: Improper Output Neutralization for Logs [https://cwe.mitre.org/data/definitions/117.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://cwe.mitre.org/data/definitions/93.html]
CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') [https://logback.qos.ch/manual/layouts.html#replace]
OWASP Security Logging [https://github.com/javabeanz/owasp-security-logging]
github-actions / SpotBugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in com.yubico.yubikit.core.internal.codec.DefaultBase64Codec.toString(byte[]): new String(byte[])
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behavior to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
github-actions / SpotBugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in com.yubico.yubikit.core.internal.codec.DefaultBase64Codec.toUrlSafeString(byte[]): new String(byte[])
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behavior to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.