🛡️ Sentinel: [CRITICAL/HIGH] Fix buffer overflow in mmdblookup#173
🛡️ Sentinel: [CRITICAL/HIGH] Fix buffer overflow in mmdblookup#173
Conversation
Replaced VLA with heap allocation in `str_split` to prevent stack overflow. Implemented safe string expansion handling with `realloc`. Ensured `open_memstream` buffer is finalized with `fclose` before modification to prevent use-after-free/double-free. Co-authored-by: Jules Agent <jules@agent.com> Co-authored-by: rgerhards <1482123+rgerhards@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello @rgerhards, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses critical and high-severity memory safety vulnerabilities within the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fae4bd0189
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (tempbuf == NULL) { | ||
| LogError(0, RS_RET_OUT_OF_MEMORY, "mmdblookup: malloc failed in str_split"); | ||
| return; |
There was a problem hiding this comment.
Propagate str_split allocation failures to caller
When malloc/realloc fails, str_split logs and returns without transforming membuf, but doAction_NoStrings still parses and consumes that buffer as if conversion succeeded. In this module the conversion step is required to turn MMDB_dump_entry_data_list output into JSON (for example, it strips <...> markers), so this failure path can produce NULL/invalid JSON values and push bad data through msgAddJSON instead of cleanly failing the action. Please return an error status from str_split and abort processing on failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Code Review
This pull request effectively addresses critical security vulnerabilities in mmdblookup.c, specifically a stack-based buffer overflow from a Variable Length Array, a heap-based buffer overflow, and a use-after-free condition related to open_memstream. The changes correctly implement fixes such as replacing VLA with heap allocation, resizing destination buffers, and ensuring proper memory stream closure. While the SAST reconnaissance pass reported no vulnerabilities, this was due to all files being empty, preventing a full scan. The implemented fixes significantly improve the module's security and stability, with a minor suggestion for performance improvement.
| } | ||
| *membuf = new_membuf; | ||
| } | ||
| strcpy(*membuf, tempbuf); |
There was a problem hiding this comment.
🚨 Severity: HIGH
💡 Vulnerability: A Variable Length Array (VLA) in
str_split(mmdblookup.c) could cause stack overflow. String expansion without bounds checking could cause heap overflow.🎯 Impact: Potential DoS or RCE if malicious data is processed.
🔧 Fix: Replaced VLA with heap allocation (
malloc/realloc). Added safe stream handling (fclosebefore modification).✅ Verification: Verified logic with standalone test case. Verified syntax via code review.
PR created automatically by Jules for task 7357544321937131368 started by @rgerhards