The Wayback Machine - https://web.archive.org/web/20220311131457/https://github.com/github/codeql/pull/8380
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

JS: support that the base is not a method-call in getAChainedMethodCall #8380

Merged
merged 2 commits into from Mar 10, 2022

Conversation

erik-krogh
Copy link
Contributor

@erik-krogh erik-krogh commented Mar 9, 2022

Gets a TP for CVE-2021-46704

Evaluation was uneventful.


Consider the below.

result = DataFlow::moduleImport("foo").getAnInstantiation().getAMethodCall*().getAMethodCall("bar");

This will not flag the below:

const Foo = require("foo");
const inst = new Foo();
const result = inst.bar();

Because DataFlow::moduleImport("foo").getAnInstantiation().getAMethodCall*() is restricted to the type DataFlow::CallNode, even if we take 0 steps through the transitive closure.

@github-actions github-actions bot added the JS label Mar 9, 2022
@erik-krogh erik-krogh marked this pull request as ready for review Mar 9, 2022
@erik-krogh erik-krogh requested a review from as a code owner Mar 9, 2022
@kaeluka kaeluka self-requested a review Mar 10, 2022
kaeluka
kaeluka previously approved these changes Mar 10, 2022
Copy link
Contributor

@kaeluka kaeluka left a comment

So, I'm understanding this correctly — the problem in your example is that in the third line below, inst is not a CallNode and therefore the bar call is not found? That's quite an easy mistake to make. As you're on a roll, this might be worth doing a ql-for-ql query for?

const Foo = require("foo");
const inst = new Foo();
const result = inst.bar();

Also, the check asks for a change note, but I think you can disable that.

javascript/ql/lib/semmle/javascript/dataflow/Sources.qll Outdated Show resolved Hide resolved
Co-authored-by: Stephan Brandauer <kaeluka@github.com>
esbena
esbena approved these changes Mar 10, 2022
@erik-krogh erik-krogh merged commit d316ad1 into github:main Mar 10, 2022
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
HTTPS · web.archive.org
← Home