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

[Snyk] Security upgrade PyJWT from 1.4.2 to 1.5.1 #729

Merged
merged 7 commits into from
Jul 21, 2020

Conversation

snyk-bot
Copy link
Contributor

Snyk has created this PR to fix one or more vulnerable packages in the `pip` dependencies of this project.

Changes included in this PR

  • Changes to the following files to upgrade the vulnerable dependencies to a fixed version:
    • monkey/monkey_island/requirements.txt
⚠️ Warning
Flask-JWT 0.3.2 has requirement PyJWT<1.5.0,>=1.4.0, but you have PyJWT 1.7.1.

Vulnerabilities that will be fixed

By pinning:
Severity Issue Upgrade Breaking Change Exploit Maturity
high severity Authentication Bypass
SNYK-PYTHON-PYJWT-40693
PyJWT:
1.4.2 -> 1.5.1
No No Known Exploit

Some vulnerabilities couldn't be fully fixed and so Snyk will still find them when the project is tested again. This may be because the vulnerability existed within more than one direct dependency, but not all of the effected dependencies could be upgraded.

Check the changes in this PR to ensure they won't cause issues with your project.


Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open fix PRs.

For more information:
🧐 View latest project report

🛠 Adjust project settings

📚 Read more about Snyk's upgrade and patch logic

The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-PYJWT-40693
@ShayNehmad
Copy link
Contributor

ShayNehmad commented Jul 16, 2020

Seems like Flask-JWT is abandoned (no commits since 2015) and we need to upgrade to https://github.com/vimalloc/flask-jwt-extended instead which is maintained.

https://travis-ci.com/github/guardicore/monkey/builds/175862097#L474

$ pipdeptree --warn fail
Warning!!! Possibly conflicting dependencies found:
* Flask-JWT==0.3.2
 - PyJWT [required: >=1.4.0,<1.5.0, installed: 1.7.1]

@ShayNehmad ShayNehmad requested a review from VakarisZ July 21, 2020 14:30
@ShayNehmad ShayNehmad self-assigned this Jul 21, 2020
app.config['JWT_EXPIRATION_DELTA'] = env_singleton.env.get_auth_expiration_time()

# See https://flask-jwt-extended.readthedocs.io/en/stable/options
app.config['JWT_TOKEN_LOCATION'] = ['headers']
Copy link
Contributor

Choose a reason for hiding this comment

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

Already a default, why specify?

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed

app.config['JWT_TOKEN_LOCATION'] = ['headers']
app.config['JWT_ACCESS_TOKEN_EXPIRES'] = env_singleton.env.get_auth_expiration_time()
# Invalidate the signature of JWTs between server resets.
app.config['JWT_SECRET_KEY'] = str(uuid.uuid4())
Copy link
Contributor

Choose a reason for hiding this comment

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

It's stored in mongodb between resets?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope - I meant Python process restarted, fixed the doc.

# If the user and password have been previously registered
if self._authenticate(username, secret):
access_token = flask_jwt_extended.create_access_token(identity=user_store.UserStore.username_table[username].id)
logger.debug(f"Created access token for user {username}: {access_token}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to log access token?

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed to only log first 4 chars (useful for debugging as I've discovered)


return decorator
# See https://flask-jwt-extended.readthedocs.io/en/stable/custom_decorators/
def jwt_required(fn):
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@ShayNehmad ShayNehmad Jul 21, 2020

Choose a reason for hiding this comment

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

It doesn't since it raises 500 instead of a more accurate 401 on JWT errors (like invalidation due to key change).

@codecov
Copy link

codecov bot commented Jul 21, 2020

Codecov Report

Merging #729 into develop will decrease coverage by 0.01%.
The diff coverage is 51.61%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #729      +/-   ##
===========================================
- Coverage    59.86%   59.85%   -0.02%     
===========================================
  Files          147      147              
  Lines         4784     4795      +11     
===========================================
+ Hits          2864     2870       +6     
- Misses        1920     1925       +5     
Impacted Files Coverage Δ
monkey/monkey_island/cc/resources/auth/auth.py 50.00% <46.42%> (+1.85%) ⬆️
monkey/monkey_island/cc/environment/__init__.py 77.90% <100.00%> (ø)
monkey/monkey_island/cc/resources/test/log_test.py 53.84% <100.00%> (ø)
...key/monkey_island/cc/resources/test/monkey_test.py 77.77% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d51667a...2bbb2d2. Read the comment docs.

@ShayNehmad ShayNehmad merged commit 27b1c7a into develop Jul 21, 2020
@ShayNehmad ShayNehmad deleted the snyk-fix-8605a12c0d6e7129269774950a531099 branch July 21, 2020 15:56
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.

3 participants