Skip to content

[porcupiney.hairs]: [Python] Add Flask Path injection sinks #407

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

Closed
ghost opened this issue Jul 19, 2021 · 18 comments
Closed

[porcupiney.hairs]: [Python] Add Flask Path injection sinks #407

ghost opened this issue Jul 19, 2021 · 18 comments
Labels
All For One Submissions to the All for One, One for All bounty

Comments

@ghost
Copy link

ghost commented Jul 19, 2021

Query

Relevant PR: github/codeql#6330

CVE ID(s)

No CVE's issued yet.

Report

Flask's send_file and send_from_directory calls can allow a remote attacker to potentially access any file stored on the system if the path is controlled by them.

This can lead to a variety of issues such as

  • Credential leakage : An attacker may be able to access a config file with credentials stored in it.
  • Downloading of source code : An attacker may be able to download the code of the entire website which can lead to further compromise.
  • In certain cases, it may even result in remote code execution too.

This query modifies the existing Python path injection query to add support for the same.

Result(s)

The query is not run on lgtm yet. However, by using fuzzy search, I was able to find out multiple true positives for this query.

@ghost ghost added the All For One Submissions to the All for One, One for All bounty label Jul 19, 2021
@ghost ghost changed the title [USERNAME]: [SUMMARY] [porcupiney.hairs]: [Python] Add Flask Path injection sinks Jul 19, 2021
@antonio-morales
Copy link
Contributor

Hi @porcupineyhairs

in order to meet the new submission criteria, you need to support your submission with a CVE mapping (old or new) not previously covered by any existing CodeQL query. See https://securitylab.github.com/bounties for more details.

And unfortunately, I can not consider your search in Github as valid results.

I look forward to your CodeQL results :)

Regards,
Antonio.

@ghost
Copy link
Author

ghost commented Oct 21, 2021

@antonio-morales Just a quick update. I have found multiple valid results with this query. I applied for corresponding CVE mappings from MITRE a couple of weeks back but haven't heard back from them yet. So looks like this bounty application may have to be kept pending for some more time.

@RasmusWL
Copy link
Member

Since the PR was looking good, I merged it to be part of the standard modeling for Python.

@ghost
Copy link
Author

ghost commented Oct 29, 2021

With @RasmusWL's PR merged, this query now detects CVE-2021-41185. I have also created a new Pr github/codeql#7009 to add a few more sanitizers. These should help reduce FP's.

@haby0
Copy link

haby0 commented Nov 1, 2021

The CVE I found was used.

@ghost
Copy link
Author

ghost commented Nov 1, 2021

@haby0 My query has multiple alerts. I have applied for a CVE for some of these alerts. But it's been almost two months now and I haven't been issued a CVE-ID by MITRE. To be clear, this query has enough detection to qualify for Bug Slayer but in the absence of a CVE-ID I can't do much.

Your CVE which I use here is just speeding things up a bit while I wait on MITRE for a CVE ID. I am not claiming bounty for an otherwise ineligible report.

@haby0
Copy link

haby0 commented Nov 2, 2021

@haby0 My query has multiple alerts. I have applied for a CVE for some of these alerts. But it's been almost two months now and I haven't been issued a CVE-ID by MITRE. To be clear, this query has enough detection to qualify for Bug Slayer but in the absence of a CVE-ID I can't do much.

Your CVE which I use here is just speeding things up a bit while I wait on MITRE for a CVE ID. I am not claiming bounty for an otherwise ineligible report.

I think you may have misunderstood my meaning. My original intention was mentioned in #463 yesterday.

@pwntester
Copy link
Contributor

The CVE I found was used.

When this query was submitted there was no requirement for the query to find a new or existing CVE.
With the current requirements, its not required that your queries find a novel CVE, just that it finds any existing CVE. Its not mandatory that it needs to find a novel CVE found by you.

@haby0
Copy link

haby0 commented Nov 2, 2021

The CVE I found was used.

When this query was submitted there was no requirement for the query to find a new or existing CVE. With the current requirements, its not required that your queries find a novel CVE, just that it finds any existing CVE. Its not mandatory that it needs to find a novel CVE found by you.

@pwntester Well, I think this CVE can be used directly. @porcupineyhairs

@ghost
Copy link
Author

ghost commented Nov 10, 2021

The PR is now merged.

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Test run.

For information, the evaluation workflow is the following:
Initial triage > Test run > Results analysis > Query review > Final decision > Pay > Closed

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Results analysis.

For information, the evaluation workflow is the following:
Initial triage > Test run > Results analysis > Query review > Final decision > Pay > Closed

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Query review.

For information, the evaluation workflow is the following:
Initial triage > Test run > Results analysis > Query review > Final decision > Pay > Closed

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Final decision.

For information, the evaluation workflow is the following:
Initial triage > Test run > Results analysis > Query review > Final decision > Pay > Closed

@ghost
Copy link
Author

ghost commented Nov 23, 2021

This query has found the following CVE's and has approx 3-4 more pending processing currently in the pipeline.

@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Pay.

For information, the evaluation workflow is the following:
Initial triage > Test run > Results analysis > Query review > Final decision > Pay > Closed

@xcorail
Copy link
Contributor

xcorail commented Nov 30, 2021

Created Hackerone report 1413541 for bounty 352580 : [407] [porcupiney.hairs]: [Python] Add Flask Path injection sinks

@xcorail xcorail closed this as completed Nov 30, 2021
@ghsecuritylab
Copy link
Collaborator

Your submission is now in status Closed.

For information, the evaluation workflow is the following:
Initial triage > Test run > Results analysis > Query review > Final decision > Pay > Closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
All For One Submissions to the All for One, One for All bounty
Projects
None yet
Development

No branches or pull requests

6 participants