Skip to content

Conversation

@ekse
Copy link
Owner

@ekse ekse commented Dec 2, 2025

🐕 Corgea issued a PR to fix a vulnerability found in lib/libwasm.c.

It is CWE-122: Heap-based Buffer Overflow that has a severity of 🔴 Critical.

🪄 Fix explanation

The fix mitigates a heap overflow by validating the parameter count before allocation and dynamically allocating the params buffer only for the declared count, preventing overruns beyond the maximum limit of 10 parameters.
- Removed fixed-size allocation "calloc(10, sizeof(WasmValueType))", which risked overflow if actual param_count was larger.
- Added a check "if (entry->param_count > 10) goto parse_error;" to enforce WebAssembly’s maximum parameter limit.
- Allocated "entry->params" dynamically with size based on "entry->param_count" to fit exactly the required parameters.
- Added NULL check after allocation to handle memory failures safely, redirecting to "parse_error" if allocation fails.

💡 Important Instructions

Ensure that the parse_error label correctly frees any previously allocated resources to avoid memory leaks during error handling.

See the issue and fix in Corgea.

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.

2 participants