OpenAPITools / OpenAPITools/openapi-generator
[BUG] LogForging security issue in ApiClient.java
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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