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

Auth Bypass to RCE in Airflow #456

Merged
merged 19 commits into from
May 20, 2024

Conversation

am0o0
Copy link
Contributor

@am0o0 am0o0 commented Apr 6, 2024

Hi, it is according to this PRP issue #428

@leonardo-doyensec leonardo-doyensec self-assigned this Apr 12, 2024
Copy link
Collaborator

@leonardo-doyensec leonardo-doyensec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @am0o0,
Thank you for your contribution! I did a review of this plugin, and I've noticed that it is missing the require Java formatting. I highly recommend to run Google's Java formatter in order to be compliant with the standards.

You can do it by following the guidelines in the following repo https://github.com/google/google-java-format

Also, you can find my comments on your contribution below.
Feel free to reach out.

~ Leonardo (Doyensec)

fix wildcard imports
fix recommendation and title of detection report
set a constant for session cookie payload
Copy link
Collaborator

@leonardo-doyensec leonardo-doyensec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @am0o0,
Thank you for your changes. I'm noticing that the package statements are still missing a space from the line above. I've also found some minor stylistic issues to address, you can find them below.

~ Leonardo (Doyensec)

@maoning maoning assigned am0o0 and unassigned leonardo-doyensec Apr 25, 2024
@maoning
Copy link
Collaborator

maoning commented Apr 25, 2024

@am0o0 Please update your PR according to the feedback, so that we can merge your PR in asap.

@am0o0
Copy link
Contributor Author

am0o0 commented Apr 26, 2024

Hi, @leonardo-doyensec, apologize for the delay.

@leonardo-doyensec
Copy link
Collaborator

Hi @am0o0 ,
thank you for your changes. However after the last commits, the plugins no longer builds.

~ Leonardo (Doyensec)

@am0o0
Copy link
Contributor Author

am0o0 commented May 7, 2024

@leonardo-doyensec I fixed the issue.

@leonardo-doyensec
Copy link
Collaborator

LGTM - Approved
@maoning you can merge it.

Reviewer: Leonardo, Doyensec

Plugin: Auth Bypass Lead to RCE in Apache Airflow
Feedback: The overall quality is good. The security testbed was easy to deploy. Although some aspects of the formatting were missing, the plugin detection and exploitation phases were nicely done.
Drawbacks: None

.build(),
networkService);

Uninterruptibles.sleepUninterruptibly(Duration.ofSeconds(25));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make the time here injected via guice? So that the unit test can inject a different value to make the test run faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried a lot to work with Guice but I couldn't succeed :(
If necessary please confirm it and I can put my time into learning Guice as a first step :).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you choose the value of 25 here? At least for now, let's switch to 20 if there is no constraint to it, that allows the test to pass. I will give a quick go at having the guice binding.

@maoning
Copy link
Collaborator

maoning commented May 8, 2024

@am0o0 Could you check if the vulnerable configuration of the service recorded at https://github.com/google/security-testbeds/blob/6022938f728d5114f4b9c1d55bb498872018bd03/apache/airflow/CVE-2020-17526/README.md is still working as intended. I tried to do the manual verification and run the plugin, neither works.

@am0o0
Copy link
Contributor Author

am0o0 commented May 9, 2024

@maoning as this PR took one and half months to be reviewed there is a benefit for this :)
the sessions will expire after a while and I can't set the expiration date anyway.
but the good news and the most interesting part is that I found a very helpful burp suite extension that can be used to sign and unsign different kinds of tokens like Flask session tokens Django session tokens Expressjs session tokens and more.
I copied parts of the crypto signer that we need to generate a fresh session cookie signed by a constant secret key each time.

the source code of the burp suite plugin:
https://github.com/d0ge/sign-saboteur/blob/main/src/main/java/one/d4d/signsaboteur/itsdangerous/crypto/DangerousTokenSigner.java

if you are interested as a bounty PRP I can wrap all of these into very simple and smaller Java classes because it is really helpful. After all, we have submissions that need to sign a flask session key with a constant secret key.

you can look at the TokenSigner class as an example of what I'm explaining.

Copy link
Member

@tooryx tooryx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some additional comments. This PR is almost ready though. Thank you for your contribution!

import com.google.common.primitives.Bytes;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the explicit list of import, do not use wildcards

.build(),
networkService);

Uninterruptibles.sleepUninterruptibly(Duration.ofSeconds(25));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you choose the value of 25 here? At least for now, let's switch to 20 if there is no constraint to it, that allows the test to pass. I will give a quick go at having the guice binding.

@am0o0
Copy link
Contributor Author

am0o0 commented May 15, 2024

How did you choose the value of 25 here?

The 10 seconds was the time to get an out-of-band callback for a fresh server, so I thought it should be more for an airflow application with multiple deployments.

@tooryx
Copy link
Member

tooryx commented May 16, 2024

Ack, thank you! I will give a try at the guice change when I have a bit of time (probably early next week) and come back to you. Otherwise we will just reduce the value so that unit tests pass.

@tooryx
Copy link
Member

tooryx commented May 16, 2024

Hi @am0o0,

I found a plugin that you can use to implement the Guice injection. See the phpunit detector

Here are the required steps:

  1. You need to define an annotation for the wait time that will be used in the plugin, see Annotations.java
  2. You will need to define a provider for this value, in the BootstrapModule
  3. Ensure that the parameter is injected in the Detector
  4. You will then be able to bind a specific value in the tests

Let me know if you encounter any issue in the process.

Cheers,
~tooryx

@am0o0
Copy link
Contributor Author

am0o0 commented May 17, 2024

@tooryx thank you a lot for helping me on this!

@tooryx
Copy link
Member

tooryx commented May 20, 2024

Thank you for your work on this @am0o0. I asked a second member of the team to take a quick look. I expect this should be merged before the end of the week.

Cheers,
~tooryx

@copybara-service copybara-service bot merged commit af19eb6 into google:master May 20, 2024
5 checks passed
@tooryx
Copy link
Member

tooryx commented May 20, 2024

Hi @am0o0,

Your PR has been merged. This usually means a reward will be granted. Google will start the internal QC process and the reward amount will be determined based on the quality of the detector report. Please be patient and allow up to a week for the QC process to finish. You'll be notified once the decision is made.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants