Skip to content

Conversation

@patryk4815
Copy link

Hi. I found a "Function" workaround and now in safe mode we can execute dynamic code like as "eval".
I think it is security vuln and need CVE?

Function("){return 1337})//", "return this")();

BTW Why function arguments are not sanitized? It just concatenate string.

@drsm
Copy link
Contributor

drsm commented Feb 1, 2021

@patryk4815

nice catch!

but unlikely exploitable, 'cause in order to do this, the stuff before the function body should came from non-trusted source.

there is only an ability to forge an intentionally malicious configuration that bypass a code execution restriction.

@drsm
Copy link
Contributor

drsm commented Feb 1, 2021

BTW, it would be nice to document that in "non-safe" mode it's up to the caller to sanitize inputs.

@xeioex
Copy link
Contributor

xeioex commented Feb 1, 2021

Hi @patryk4815,

Thanks for the patch, will be committed.

I think it is security vuln and need CVE?

This is bug but not a security vulnerability, because in njs threat model the code is a part of nginx configuration, and the configuration is expected to be a trusted source (it also contains certificates, for example).

@xeioex
Copy link
Contributor

xeioex commented Feb 1, 2021

@patryk4815

BTW Why function arguments are not sanitized? It just concatenate string.

Mostly because dynamic execution methods like eval() and Function() are not expected to be used in njs at all.
Their support is limited, and was added to increase test262 coverage of other functionality.

@xeioex xeioex added the bug label Feb 2, 2021
@xeioex xeioex added this to the 0.5.1 milestone Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants