Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions r2c-david.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

public class TestLog3 {
private final static Logger log = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// ruleid: crlf-injection-logs-deepsemgrep-sanitizer
log.info("foo"+request.getParameter("param"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. Please use Jsoup.clean() to sanitize logger data.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>r2c-david.java</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0("<b>[Line: 7]</b> request.getParameter(#quot;param#quot;)")
        end
        %% Intermediate

        %% Sink

        subgraph Sink
            direction LR

            v1("<b>[Line: 7]</b> log.info(#quot;foo#quot;+request.getParameter(#quot;param#quot;));")
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    File0:::invis

    %% Connections

    Source --> Sink

    %% Clickable

    click v0 href "https://github.com/Semgrep-NA-Workshop/JavaSpringVulny-app/blob/de5c809ae7f572507cacd9f4831419c3f1f3e940/r2c-david.java#L7" "View in source" _blank
    click v1 href "https://github.com/Semgrep-NA-Workshop/JavaSpringVulny-app/blob/de5c809ae7f572507cacd9f4831419c3f1f3e940/r2c-david.java#L7" "View in source" _blank
Loading
Ignore this finding from crlf-injection-logs-deepsemgrep-customized.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semgrep Assistant thinks you might be able to fix the finding like this:

Suggested change
log.info("foo"+request.getParameter("param"));
log.info("foo" + Jsoup.clean(request.getParameter("param"), Whitelist.none()));

AI-generated comment. Please review the code carefully.

response.getWriter().append("Served at: ").append(request.getContextPath());
}
}