augustd / owasp-security-logging Goto Github PK
View Code? Open in Web Editor NEWOWASP Security Logging library for Java
Home Page: https://www.owasp.org/index.php/OWASP_Security_Logging_Project
License: Apache License 2.0
OWASP Security Logging library for Java
Home Page: https://www.owasp.org/index.php/OWASP_Security_Logging_Project
License: Apache License 2.0
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-45046
Log4J needs upgrade to 2.16.0
Right now we have CRLFConverter to replace newline and carriage return with underscore, which prevents CRLF log injection.
Do we have a way to prevent Backspace injection into the logs?
Create a document that shows how the security-logging library should be implemented by walking through an implementation on a known insecure web application, Webgoat. This document would cover both the technical aspects of _what_ to do as well as the business aspects of _why_ to do it.
A recommended outline would be:
VersionEye is no more. See: https://blog.versioneye.com/2017/10/19/versioneye-sunset-process/
Snyk.io may be a good replacement: https://snyk.io
https://cwe.mitre.org/data/definitions/502.html
Introduced through: javabeanz/owasp-security-logging@javabeanz/owasp-security-logging#38dce79070bb868a9c734cb24cbfb6fece629c05 › org.apache.logging.log4j:[email protected]
Remediation: Upgrade to org.apache.logging.log4j:[email protected].
The masking of information is great when the system is running flawlessly in production but sometimes, the provided information is crucial to track down the source of a bug.
In my case, I'd like to protect passwords and JWT tokens.
But I also need a way to see them in the logs when a problem comes up.
Discussion of possible solutions:
setFinal(false)
on the field at runtime.Are there any plans to support java.util.logging
? With Java 8, the Logger API has been improved significantly. Nevertheless I'm aware of the fact, that it has no equivalent to the marker concept, which seems to be essential for owasp-security-logging
.
Best regards,
Jens
I looked at this https://github.com/javabeanz/owasp-security-logging/wiki/Masking
However that is very limited and requires logging statements to be written in a very specific way.
I have created this regex based Logback converter. https://gist.github.com/rahulaga/8bd7ca7b521a7858e86c0a51fffe3f03
Configure it as such
<conversionRule conversionWord="maskedMsg" converterClass="MaskingConverter" /> <property name="CONSOLE_LOG_PATTERN" value="%mdc{TID} %date %-5level [%thread] %logger{0} - %maskedMsg{ password|token, username, apiKey, email }%n" />
I think it would be useful for the community and something anyone could easily drop in.
please set version to 1.1.6-SNAPSHOT
Dear all,
is it intended, that the ...mask.MaskingConverter only masks arguments of log events which only have the "Confidential" Marker? Since MultiMarkers are one of the main features of this package, I would expect them to be supported as well.
This would just require eventMarker.contains(SecurityMarkers.CONFIDENTIAL)
instead of eventMarker.equals(SecurityMarkers.CONFIDENTIAL)
in the convert()
method.
Thank you for feedback.
Hello guys!
I don't know why but with the Spring Boot, nothing of the Markers works...
My pom.xml
:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.3.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <!-- annotations to simplify the code -->
<version>1.18.18</version>
</dependency>
<dependency>
<groupId>org.owasp</groupId>
<artifactId>security-logging-log4j</artifactId>
<version>LATEST</version>
</dependency>
My code:
public final class RequestLogger extends Logger {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(RequestLogger.class);
public RequestLogger() {
super();
// log shell environment variables
log.info(SecurityMarkers.CONFIDENTIAL, "password={}", "aa");
}
// simplified to read easier
}
Output:
2021-06-28 19:33:09,201 restartedMain WARN Log4j does not support detached Markers. Returned Marker [RESTRICTED] will be unchanged.
2021-06-28 19:33:09,205 restartedMain WARN Log4j does not support detached Markers. Returned Marker [CONFIDENTIAL] will be unchanged.
2021-06-28 19:33:09,209 restartedMain WARN Log4j does not support detached Markers. Returned Marker [SECRET] will be unchanged.
2021-06-28 19:33:09,212 restartedMain WARN Log4j does not support detached Markers. Returned Marker [TOPSECRET] will be unchanged.
2021-06-28 19:33:09,217 restartedMain WARN Log4j does not support detached Markers. Returned Marker [SECURITY SUCCESS] will be unchanged.
2021-06-28 19:33:09,221 restartedMain WARN Log4j does not support detached Markers. Returned Marker [SECURITY FAILURE] will be unchanged.
2021-06-28 19:33:09,225 restartedMain WARN Log4j does not support detached Markers. Returned Marker [SECURITY AUDIT] will be unchanged.
2021-06-28 19:33:09,228 restartedMain WARN Log4j does not support detached Markers. Returned Marker [EVENT SUCCESS] will be unchanged.
2021-06-28 19:33:09,232 restartedMain WARN Log4j does not support detached Markers. Returned Marker [EVENT FAILURE] will be unchanged.
2021-06-28 19:33:09.236 INFO 82744 --- [ restartedMain] c.i.i.a.l.RequestLogger : password=aa
I already read this: #26
Can you help me?
oraclejdk7 and openjdk7 if possible
If an exception is created with a message containing \r or \n, they are not replaced by the CRLFConverter class
java.lang.IllegalArgumentException: Unknown Argument inject message
Injection 1
Injection 2
Injection 3
!
at test.Main(test.java:24)
when using
try {
String invalidArgs = "inject message\nInjection 1\nInjection 2\nInjection 3\n!";
throw new IllegalArgumentException("Unknown Argument: "+invalidArgs);
} catch (Exception e) {
LOGGER.error(e);
}
My logback configuration contains :
<configuration debug="false" >
<conversionRule conversionWord="crlf" converterClass="org.owasp.security.logging.mask.CRLFConverter" />
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %crlf(%msg) %n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
In version 1.3.0 of logback-classic the method isCyclic()
was introduced for the interface ch.qos.logback.classic.spi.IThrowableProxy
, trying to use the org.owasp.security.logging.mask.CRLFThrowableConverter
in this environment will result in the following error message:
java.lang.AbstractMethodError: Receiver class org.owasp.security.logging.mask.CRLFThrowableProxy does not define or inherit an implementation of the resolved method 'abstract boolean isCyclic()' of interface ch.qos.logback.classic.spi.IThrowableProxy.
Spring Boot 3.1 is using logback-classic 1.4.7, this prevents the usage of the CRLFThrowableConverter in the current version 1.1.7.
I think a new release of security-logging-logback using logback-classic 1.4.x could address this issue.
In MDCFilter, Line 40:
String ipAddress = request.getHeader("X-FORWARDED-FOR");
Need a better means to get the IP address. The "X-FORWARDED-FOR" request header can be tampered with by an attacker to hide their tracks.
This request aims to enhance the accessibility and usability of owasp-security-logging by publishing its artifacts on Maven Central. The release of the latest changes from the master branch will simplify integration, particularly for Spring Boot 3 projects, eliminating the need for manual builds.
In response to the log4j issue, the logback team has released 1.28 to cover a more unlikely scenario where a similiar exploit can happen as described here to quote:
However, logback may make JNDI calls from within its configuration file. This was recently reported in LOGBACK-1591 as a vulnerability of lesser severity. In response, we have released logback version 1.2.8. Please upgrade.
...
[ERROR] Failed to execute goal com.buschmais.jqassistant.scm:jqassistant-maven-p
lugin:1.1.4:scan (default) on project security-logging: Execution default of goa
l com.buschmais.jqassistant.scm:jqassistant-maven-plugin:1.1.4:scan failed: Unab
le to load the mojo 'scan' in the plugin 'com.buschmais.jqassistant.scm:jqassist
ant-maven-plugin:1.1.4'. A required class is missing: javax/activation/DataSource
The SecurityUtil class provides various useful features. However the benefit of bindSystemStreamsToSLF4J
may be improved by adding a way to differentiate the noisy sysout/syserr from the other info logs produced by the same class. This could be achieved by introducing another Logger instance or at least allowing to adjust the log level.
Best regards,
Jens
I used the log4j2.xml and test Java code for a simple CONFIDENTIAL log from the src/test/resources and src/test/java/...MaskingRewritePolicyTest.java. Only thing that looks out of place:
2017-11-28 23:18:20,692 main WARN Log4j does not support detached Markers. Returned Marker [CONFIDENTIAL] will be unchanged.
log4j-api: 2.10.0
log4j-core: 2.10.0
log4j-slf4j-impl: 2.10.0
security-logging-log4j: 1.1.3
security-logging: 1.1.3
Smells like a versioning issue. I'd love to be able to recommend my employer use this logger and masking would be nice. I don't see any documentation on "packages" in the but I added the package of the MaskingRewritePolicy.java... I'm certain I am using parameters.
covert logging adds an option to log info without attackers being able to detect or alter it. Chapter 6 of Logging and log managment https://www.amazon.com/Logging-Log-Management-Authoritative-Understanding/dp/1597496359
The Core Infrastructure Initiative badge describes itself as "... a way for Free/Libre and Open Source Software (FLOSS) projects to show that they follow best practices."
This project has been registered and the current progress can be seen here:
https://bestpractices.coreinfrastructure.org/projects/140
Overall, here is the status of the major sections of this certification:
Note: in order keep track of these related items, please update this description to include links to 'Children' tickets and also link to this ticket from the 'Children' tickets to help keep this work associated with each other. Also, I will be assigning this to myself, but only to show that it does have someone looking at it. If you feel moved to contribute to this work, please do :)
https://github.com/javabeanz/owasp-security-logging/wiki/Log-Forging describes the provided CRLFConverter
class to prevent log forging. However this converter is not sufficient since there are other characters beside \n
and \r
that should be filtered out, for example the unicode character U+0085 (next line) is one of these.
This ticket is a child to #8 (see that issue for background information)
The two items marked as 'unknown' for this part of the certification are
These two items should be reviewed and any project changes to address them should be implemented. When the team believes these are satisfied, the certification site can be updated and this ticket closed
i am trying this
log.info(SecurityMarkers.CONFIDENTIAL, "password={}","asd");
output is:
2020-05-21 13:37:55.472 INFO INFOid --- [nio-8080-exec-1] c.m.b.e.r.ConsumerApi : password=asd
https://codecov.io/gh/javabeanz/owasp-security-logging is 38% rather low, we can do better.
This ticket is a child to #8 (see that issue for background information)
The two items marked as 'unknown' for this part of the certification are
These two items should be reviewed and any project changes to address them should be implemented. When the team believes these are satisfied, the certification site can be updated and this ticket closed
in logback RichContext
Many of the issues in the Codacy code quality report are reported on test code. Test code should be excluded to produce an accurate report on the final code library.
In SecurityLoggingLayout.doLayout(ILoggingEvent event):
Is there any reason to not use a StringBuilder instead of StringBuffer? StringBuilder is not synchronized so it should have better performance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.