Can we remove use of eval in math.ts? #9056
colinlin-stripe
started this conversation in
General
Replies: 1 comment
-
|
Only AI would come up with using eval to parse math expressions and have a whitelist of allowed characters, rather then just using an algebraic notation library... Here's the part of the code that does this, this just looks like a security vulnerability waiting to happen, there could be a weird edge case in the JS spec that lets you run arbitrary code using only these characters const validStr = /^[+\-\d.\s*/%()]+$/.test(str);
if (!validStr) {
if (fallback) {
return fallbackValue;
}
throw new Error('Invalid characters in string');
}
const value = eval(str); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Are we making use of
evalin this math library anywhere in librechat?I see it being used in
banViolation.js
cacheConfig.js
seems like it can be replaced by
parseIntorparseFloat@danny-avila
is
mathbeing used anywhere else in the codebase?We would like to avoid use of
evalas it opens up the risk of injection attacksBeta Was this translation helpful? Give feedback.
All reactions