Git Product home page Git Product logo

owasp-security-logging's People

Contributors

adetlefsen-rms avatar augustd avatar backfighter avatar dependabot[bot] avatar friedeas avatar javabeanz avatar jenspiegsa avatar kklbsce avatar preichel-cg avatar rdifrango avatar snyk-bot avatar spoofzu avatar svzdvd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owasp-security-logging's Issues

Logback converter for Backspace character

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?

Document use of security-logging library

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:

  • A problem statement that describes common problems related to logging, including a description of the impact of these security issues
  • A description of how the security-logging library solves these problems
  • An introduction to Webgoat, including the problems it has with respect to logging issues
  • Walkthrough implementation of security-logging features that requires no code changes in Webgoat
  • Walkthrough implementation of security-logging features that need code changes in Webgoat
  • Additional tips for keeping the logs themselves safe.

Add documentation about a good way to disable masking during debugging

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:

  • System property. Easy to implement, too easy to tamper with, even at runtime and even when the value of the property is copied into a final variable because you can call setFinal(false) on the field at runtime.
    The same applies to using logback variables to build the log pattern.
  • Existence of a file owned by an admin / root and not modifiable by the current user. Rationale: If the attacker is an admin already, the fight is already lost. Drawback: It's pretty easy to check for root ownership and modification flags on Linux with Java 8+ but how can we do the same on Windows? Or Mac? Another advantage: The library can check the file for every log statement, so this would allow to disable masking, test, enable masking.
  • Provide a plugin API that allows developers to come up with a suitable solution. Drawback: This isn't a solution, it just allows a solution. So people will come up with all kinds of broken ways to do this, making the effort somewhat futile.

java.util.logging support

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

Versatile masking

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.

MaskingConverter does not work with MultiMarker

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.

Doesn't work with Spring Boot

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?

Log injection is possible in exception messages with CRLFConverter

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>

security-logging-logback is not compatible with logback-classic version 1.3.x (partially)

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.

Need better means to get IP address

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.

Release Latest Version of owasp-security-logging with Recent Updates

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.

Update to logback 1.28

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.

library does not build with jdk 9

...
[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

SecurityUtil.bindSystemStreamsToSLF4J()

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

Masking not working..

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.

Travis not running

We got a new pull request #53 but the Travis CI build did not run.

Travis CI does appear to have run for pull request from depend-a-bot #54 however.

Parent Ticket - Core Infrastructure Initiative (CII) badge progress

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:

  • Basics - COMPLETE
  • Change Control - COMPLETE
  • Reporting - Work is complete, need to update the coreinfrastructure.org site
  • Quality - 2 items marked as 'unknown'
  • Security - 6 items marked as 'unknown'
  • Analysis - 2 items marked as 'unmet', 1 item marked as 'unknown'
  • Future - 6 items marked as 'unknown'

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 :)

The Core Infrastructure Initiative (CII) badge - Quality Section

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

  • It is SUGGESTED that this policy on adding tests be documented in the instructions for change proposals. [tests_documented_added] Hide details
    However, even an informal rule is acceptable as long as the tests are being added in practice.
    Tests documented added justification
  • It is SUGGESTED that projects be maximally strict with warnings, but this is not always practical.

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

The Core Infrastructure Initiative (CII) badge - Reporting Section

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

  • The project MUST acknowledge a majority of bug reports submitted in the last 2-12 months (inclusive); the response need not include a fix.
    • The project SHOULD respond to most enhancement requests in the last 2-12 months (inclusive). The project MAY choose not to respond.

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

Exclude tests from code quality report

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.

Use StringBuilder

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.