-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from nicholasaleks/feature/auth
Feature/auth
- Loading branch information
Showing
15 changed files
with
201 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -58,8 +58,10 @@ def pump_db(): | |
print('Populating Database') | ||
db.create_all() | ||
|
||
admin = User(username="admin", password=random_password()) | ||
operator = User(username="operator", password=random_password()) | ||
admin = User(username="admin", email="[email protected]", password=random_password()) | ||
operator = User(username="operator", email="[email protected]", password="password123") | ||
# create tokens for admin & operator | ||
|
||
db.session.add(admin) | ||
db.session.add(operator) | ||
|
||
|
This file contains 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 @@ | ||
<!-- Start --> | ||
<h3 style="color:purple" id="bypassauthz-token"><b>Authorization Bypass :: GraphQL JWT Token Forge</b></h3> | ||
<hr /> | ||
<h5>Problem Statement</h5> | ||
<p> | ||
Without logging in a user is able to forge the user identity claim within the JWT token for the <code>me</code> query operation. | ||
</p> | ||
<h5>Exploitation Solution <button class="reveal" onclick="reveal('sol-brokenauthz-token')">Show</button></h5> | ||
<div id="sol-brokenauthz-token" style="display:none"> | ||
<pre class="bash"> | ||
|
||
query { | ||
me(token: "FORGED_TOKEN") { | ||
id | ||
username | ||
password | ||
} | ||
} | ||
</pre> | ||
</div> | ||
<!-- End --> |
This file contains 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 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,64 @@ | ||
import requests | ||
|
||
from common import GRAPHQL_URL, graph_query | ||
|
||
def test_mutation_login_success(): | ||
query = ''' | ||
mutation { | ||
login(username: "operator", password:"password123") { | ||
accessToken | ||
} | ||
} | ||
''' | ||
r = graph_query(GRAPHQL_URL, query) | ||
|
||
assert r.json()['data']['login']['accessToken'] | ||
|
||
|
||
def test_mutation_login_error(): | ||
query = ''' | ||
mutation { | ||
login(username: "operator", password:"dolevwashere") { | ||
accessToken | ||
} | ||
} | ||
''' | ||
r = graph_query(GRAPHQL_URL, query) | ||
|
||
assert r.json()['errors'][0]['message'] == 'Authentication Failure' | ||
|
||
|
||
def test_query_me(): | ||
query = ''' | ||
query { | ||
me(token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNjU2ODE0OTQ4LCJuYmYiOjE2NTY4MTQ5NDgsImp0aSI6ImI5N2FmY2QwLTUzMjctNGFmNi04YTM3LTRlMjdjODY5MGE2YyIsImlkZW50aXR5IjoiYWRtaW4iLCJleHAiOjE2NTY4MjIxNDh9.-56ZQN9jikpuuhpjHjy3vLvdwbtySs0mbdaSq-9RVGg") { | ||
id | ||
username | ||
password | ||
} | ||
} | ||
''' | ||
|
||
r = graph_query(GRAPHQL_URL, query) | ||
|
||
assert r.json()['data']['me']['id'] == '1' | ||
assert r.json()['data']['me']['username'] == 'admin' | ||
assert r.json()['data']['me']['password'] == 'changeme' | ||
|
||
|
||
def test_query_me_operator(): | ||
query = ''' | ||
query { | ||
me(token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNjU2ODE0OTQ4LCJuYmYiOjE2NTY4MTQ5NDgsImp0aSI6ImI5N2FmY2QwLTUzMjctNGFmNi04YTM3LTRlMjdjODY5MGE2YyIsImlkZW50aXR5Ijoib3BlcmF0b3IiLCJleHAiOjE2NTY4MjIxNDh9.iZ-Sifz1WEkcy1CwX4c-rzI-QgfzUMqpWr2oYr8vZ1o") { | ||
id | ||
username | ||
password | ||
} | ||
} | ||
''' | ||
|
||
r = graph_query(GRAPHQL_URL, query) | ||
|
||
assert r.json()['data']['me']['id'] == '2' | ||
assert r.json()['data']['me']['username'] == 'operator' | ||
assert r.json()['data']['me']['password'] == '******' |
Oops, something went wrong.