Skip to content

fix: add buffer-length check in winpath.cpp - #4586

Open
anupamme wants to merge 1 commit into
tesseract-ocr:mainfrom
anupamme:fix-repo-tesseract-fix-winpath-buffer-overflow
Open

fix: add buffer-length check in winpath.cpp#4586
anupamme wants to merge 1 commit into
tesseract-ocr:mainfrom
anupamme:fix-repo-tesseract-fix-winpath-buffer-overflow

Conversation

@anupamme

Copy link
Copy Markdown

Summary

Fix critical severity security issue in nsis/winpath.cpp.

Vulnerability

Field Value
ID V-001
Severity CRITICAL
Scanner multi_agent_ai
Rule V-001
File nsis/winpath.cpp:31
Assessment Likely exploitable
CWE CWE-120

Description: The code uses unsafe C string functions (strcpy and strcat) to copy and concatenate strings into a fixed-size buffer without bounds checking. If the combined length of the 'dir' parameter and PATH environment variable exceeds the buffer size, a stack buffer overflow occurs.

Evidence

Exploitation scenario: An attacker can set the PATH environment variable to a very long string before invoking the NSIS installer build process, causing buffer overflow when the function is called.

Scanner confirmation: multi_agent_ai rule V-001 flagged this pattern.

Production code: This file is in the production codebase, not test-only code.

Threat Model Context

This is a local CLI tool - exploitation requires the attacker to control command-line arguments or input files.

Changes

  • nsis/winpath.cpp

Verification

  • Build passes
  • Scanner re-scan confirms fix
  • LLM code review passed

Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 high

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant