OpenAPITools / OpenAPITools/openapi-generator

[BUG] LogForging security issue in ApiClient.java

Open
#4,718 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

The java code generated with options:
generatorName = 'java'
library = 'resttemplate'
contains security issue in the moethod:
private void logRequest(HttpRequest request, byte[] body) throws UnsupportedEncodingException { log.info("URI: " + request.getURI()); log.info("HTTP Method: " + request.getMethod()); log.info("HTTP Headers: " + headersToString(request.getHeaders())); log.info("Request Body: " + new String(body, StandardCharsets.UTF_8)); }
in line:
log.info("HTTP Headers: " + headersToString(request.getHeaders()));

The method logRequest() in ApiClient.java writes unvalidated user input to the log. An attacker could take advantage of this behavior to forge log entries or inject malicious content into the log.

The version used: 4.2.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated ApiClient.java method logRequest() for the Java resttemplate library, focusing on the HTTP Headers log statement identified in the issue. Trace how request headers reach this log call and verify that generated clients cannot emit user-controlled content that forges log entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.