-
-
Couldn't load subscription status.
- Fork 485
#809 Vault sidecar challenge2 #1405
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ee8d10e
#809: added first steps for challenge47 based on hardcoded injection
commjoen cece3c5
#809: added injection for challenge46 and 47 where missing
commjoen 1660b16
#809: more vault love
commjoen 85141dd
Fixed vault policies for k8s buildout
commjoen 2f412a1
Merge branch 'master' into 809-sidecar
commjoen f92092b
#809: hotwire and first texts
commjoen ed2223f
Apply suggestions from code review
commjoen ee5c57f
added missing component annotation and test coverage
commjoen 0362cc0
Merge remote-tracking branch 'refs/remotes/origin/809-sidecar' into 8…
commjoen 9545a94
updated test version for latest vault challenge
commjoen d874431
added todos to k8s template
commjoen 17a34d3
Merge branch 'master' into 809-sidecar
commjoen 296767a
fix for #809 deployments
commjoen 22bd98b
ported k8s challenges to cloud envs
commjoen d6bedce
Updated necessary explanations for #809
commjoen aa230c9
remove nw
commjoen 5a19b69
update minikube version in workflows
commjoen 7af23de
update container version
commjoen 258cbf3
update minikube versions for testing in workflows
commjoen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/org/owasp/wrongsecrets/challenges/kubernetes/Challenge47.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.owasp.wrongsecrets.challenges.kubernetes; | ||
|
|
||
| import org.owasp.wrongsecrets.challenges.FixedAnswerChallenge; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
|
|
||
| public class Challenge47 extends FixedAnswerChallenge { | ||
|
|
||
| private final String secret; | ||
|
|
||
| public Challenge47(@Value("${challenge47secret}") String secret) { | ||
| this.secret = secret; | ||
| } | ||
|
|
||
| @Override | ||
| public String getAnswer() { | ||
| return secret; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| === HashiCorp Vault Template Injection Part 2 | ||
|
|
||
| A developer tried to debug why his vault injection did not work. So he hardcoded the secrets "temporary" in the Vault template itself. | ||
| Can you find the secret hardcoded in the Vault Template? | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| This challenge can be solved using the following steps: | ||
|
|
||
| 1. Run `kubectl get pods -A` and find secret-challenge-xxx pod name | ||
|
|
||
| 2. Run `kubectl exec secret-challenge-xxx -c secret-challenge -n default -- cat vault/secrets/challenge46` where `xxx` is the rest of the randomly generated pod name. | ||
| to print the hardcoded value used by the developer. | ||
commjoen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Note: if you are running this on a hosted environment, where you do not have access to the Kubernetes cluster, ask the organizer of the hosted solution to execute the commands for you and return the results. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| *Why Vault Template Injection is not always a good idea?* | ||
|
|
||
| While Vault agent injection via templates can be a convenient way to manage secrets in certain scenarios, | ||
| there are situations where it might not be the best approach. | ||
|
|
||
| Templates might accidentally expose sensitive information in logs or temporary files. | ||
| If not properly configured, secrets could end up in places where they are accessible by unauthorized users or processes. | ||
|
|
||
| Let's consider an example involving a template injection attack in a scripted language like PHP: | ||
|
|
||
| . Imagine a scenario where PHP application uses a template with sensitive information | ||
| * where template can look like this: $password = "'; system('rm -rf /'); //" | ||
| . When the template is processed it can become: | ||
| * $connection = "password='; system('rm -rf /'); //" | ||
|
|
||
| To prevent such issues its crucial to ensure that the values retrieved from Vault are properly validated. | ||
commjoen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| describe('Challenge47 Tests', () => { | ||
| it('Submitting a Correct Answer', () => { | ||
| // Visit the spoiler page and extract the spoiler | ||
| cy.visit('/spoil/challenge-47') | ||
| cy.get('[data-cy=spoiler-answer]').invoke('text').then(spoilerAnswer => { | ||
| // Asserting that the spoiler is not a default value | ||
| expect(spoilerAnswer.trim()).to.not.equal('if_you_see_this_please_use_K8S_and_Vault') | ||
| expect(spoilerAnswer.trim()).to.not.be.empty | ||
|
|
||
| // Visit the challenge page and submit the spoiler as the answer | ||
| cy.visit('/challenge/challenge-47') | ||
| cy.get('#answerfield').type(spoilerAnswer.trim()) | ||
| cy.get('[data-cy=submit-textbox-btn]').click() | ||
| cy.get('[data-cy=success-alert]').should('contain', 'correct') | ||
| }) | ||
| }) | ||
|
|
||
| it('Submitting an Incorrect Answer', () => { | ||
| cy.visit('/challenge/challenge-47') | ||
|
|
||
| // Use a known incorrect answer | ||
| cy.get('#answerfield').type('definitely_wrong_answer') | ||
| cy.get('[data-cy=submit-textbox-btn]').click() | ||
|
|
||
| // Check for incorrect alert | ||
| cy.get('[data-cy=incorrect-alert]').should('contain', 'incorrect') | ||
| }) | ||
| }) |
21 changes: 21 additions & 0 deletions
21
src/test/java/org/owasp/wrongsecrets/challenges/kubernetes/Challenge47Test.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.owasp.wrongsecrets.challenges.kubernetes; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class Challenge47Test { | ||
|
|
||
| @Test | ||
| void spoilerShouldGiveAnswer() { | ||
| var challenge = new Challenge47("answer"); | ||
| assertThat(challenge.spoiler().solution()).isEqualTo("answer"); | ||
| assertThat(challenge.answerCorrect(challenge.spoiler().solution())).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| void incorrectAnswerShouldNotSolveChallenge() { | ||
| var challenge = new Challenge47("answer"); | ||
| assertThat(challenge.answerCorrect("wrong answer")).isFalse(); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.