Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

containsNoInvalidCharacters uses .includes on invalid data type #1172

Open
ElectricNroff opened this issue Jan 16, 2024 · 0 comments
Open

containsNoInvalidCharacters uses .includes on invalid data type #1172

ElectricNroff opened this issue Jan 16, 2024 · 0 comments

Comments

@ElectricNroff
Copy link
Contributor

ElectricNroff commented Jan 16, 2024

function containsNoInvalidCharacters (val) {
const invalidCharacterList = ['<', '>', '"']
if (val) {
for (const invalidCharacter of invalidCharacterList) {
if (val.includes(invalidCharacter)) {

There is currently no guarantee that val is a string when this is called. For example, val may be an object such that val.includes is not defined:

curl -g -X PUT \
-H "CVE-API-ORG: ..." \
-H "CVE-API-USER: ..." \
-H "CVE-API-KEY: ..." \
'https://cveawg-test.mitre.org/api/org/Mickey%20Mouse/user/minnie?active_roles.add[a]=b'

results in:

{"error":"BAD_INPUT","message":"Parameters were invalid","details":[{"msg":"val.includes is not a function"

Another example is a PUT of:

https://cveawg-test.mitre.org/api/org/Mickey%20Mouse/user/minnie?active_roles.add[500]=ADMIN

which fails with:

{"error":"BAD_INPUT","message":"Parameters were invalid","details":[{"msg":"val.includes is not a function"

even though an analogous request with a smaller array index succeeds:

https://cveawg-test.mitre.org/api/org/Mickey%20Mouse/user/minnie?active_roles.add[5]=ADMIN
"message":"minnie was successfully updated." ... "authority":{"active_roles":["ADMIN"]}
@jdaigneau5 jdaigneau5 moved this to Needs Triage in Issue Triage Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Triage
Development

No branches or pull requests

2 participants