KEMBAR78
Fix Integer Overflow Vulnerability in Buffer Write Method by simei2k · Pull Request #70 · robo-code/robocode · GitHub
Skip to content

Conversation

@simei2k
Copy link
Contributor

@simei2k simei2k commented May 10, 2025

Description

This pull request addresses a security vulnerability in the write() method that could lead to potential buffer overflow attacks through integer overflow in array bounds checking.

The original implementation used a pattern vulnerable to integer overflow by checking array bounds with offset + length > b.length. This can be bypassed when both offset and length are large values that, when added, overflow to become a small value that passes the boundary check.

This vulnerability was also identified in ReadyTalk/avian@0871979 and subsequently fixed.

References:

  1. ReadyTalk/avian@0871979
  2. https://nvd.nist.gov/vuln/detail/cve-2020-9488

This pull request addresses a security vulnerability in the write() method that could lead to potential buffer overflow attacks through integer overflow in array bounds checking.

The original implementation used a pattern vulnerable to integer overflow by checking array bounds with offset + length > b.length. This can be bypassed when both offset and length are large values that, when added, overflow to become a small value that passes the boundary check.

This vulnerability was also identified in ReadyTalk/avian@0871979 and subsequently fixed.

References:
1. ReadyTalk/avian@0871979
2. https://nvd.nist.gov/vuln/detail/cve-2020-9488
@flemming-n-larsen
Copy link
Member

Thank you for both identifying the vulnerability in Robocode, and also provide a PR for fixing it. ❤️

I will study the CVE and fix, and probably merge the PR as-is, unless it needs some extra consideration.

@flemming-n-larsen flemming-n-larsen self-requested a review May 13, 2025 20:39
Copy link
Member

@flemming-n-larsen flemming-n-larsen left a comment

Choose a reason for hiding this comment

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

  • I removed a misplacement of the (same) write() method before the header of the RobotFileOutputStream breaking the compilation completely.
  • Formatted the code as well.

Your vulnability fix of the RobotFileOutputStream.write() looks correct to be regarding checking the boundaries for off and len

@flemming-n-larsen flemming-n-larsen merged commit 9acfd9c into robo-code:main May 13, 2025
flemming-n-larsen added a commit that referenced this pull request May 13, 2025
@simei2k
Copy link
Contributor Author

simei2k commented May 17, 2025

Thank you @flemming-n-larsen for merging my PR. I will be submitting this as a CVE, do let me know if there are any concerns !

@flemming-n-larsen
Copy link
Member

You are welcome to summit this a a CVE. And thank you for your help. 😊

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants