fix: the calculator engine component uses unsafe mem... in exprtk.hpp#46663
fix: the calculator engine component uses unsafe mem... in exprtk.hpp#46663orbisai0security wants to merge 1 commit intomicrosoft:mainfrom
Conversation
The Calculator Engine component uses unsafe memcpy operations without bounds checking at lines 44251 and 44317 in exprtk
|
As per the documentation, if https://www.partow.net/programming/exprtk/exprtk.hpp___.html#line_44420 and as such here it is being called: https://www.partow.net/programming/exprtk/exprtk.hpp___.html#line_44452 Furthermore the fileio features have been intentionally disabled in powertoys: AI Slop. |
There was a problem hiding this comment.
Pull request overview
Fixes a critical security finding in the Calculator Engine’s vendored exprtk.hpp by adding a size check before a memcpy used for pointer extraction/type-punning.
Changes:
- Add a runtime guard to ensure the holder type
Tis large enough before copying pointer bytes intofd. - Throw a
std::runtime_errorwhen the holder size is insufficient.
Comments suppressed due to low confidence (2)
src/common/CalculatorEngineCommon/exprtk.hpp:1
- The PR description/vulnerability section calls out unsafe memcpy at two locations (lines 44251 and 44317), but this diff only shows a fix adjacent to the first site. Either include the corresponding fix for the second
memcpyoccurrence in this PR, or update the PR description/metadata so it accurately reflects what was changed.
src/common/CalculatorEngineCommon/exprtk.hpp:1 - This check is on a template type (
T) and depends only on compile-time constants (sizeof(T)andsizeof(pointer)), so it can be enforced with a compile-time constraint (e.g.,static_assert) rather than a runtimethrow. This avoids introducing a new exception-throwing path from a header (which can be problematic for builds configured without exceptions) and eliminates the runtime branch.
Summary
Fix critical severity security issue in
src/common/CalculatorEngineCommon/exprtk.hpp.Vulnerability
V-001src/common/CalculatorEngineCommon/exprtk.hpp:44251Description: The Calculator Engine component uses unsafe memcpy operations without bounds checking at lines 44251 and 44317 in exprtk.hpp. These operations perform type-punning via reinterpret_cast and copy data without validating source and destination buffer sizes, creating potential for buffer overflow when processing malicious mathematical expressions.
Changes
src/common/CalculatorEngineCommon/exprtk.hppVerification
Automated security fix by OrbisAI Security