Skip to content

[develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to >=3.0.3 to address CVE-2024-34069 #6932

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

hehe7318
Copy link
Contributor

@hehe7318 hehe7318 commented Aug 6, 2025

Description of changes

  • Upgrade connexion to ~=2.15.0rc3.
  • Upgrade Werkzeug to ~=3.0.3 to address CVE-2024-34069.
  • Upgrade serverless_wsgi.py to the latest version.
  • Changes to encoder.py, flask_app.py and etc. to adapt the version bump.

Tests

  • Changes to tests to adapt the version bump.
  • Unit tests all passed.

References

  • Link to impacted open issues.
  • Link to related PRs in other packages (i.e. cookbook, node).
  • Link to documentation useful to understand the changes.

Checklist

  • Make sure you are pointing to the right branch.
  • If you're creating a patch for a branch other than develop add the branch name as prefix in the PR title (e.g. [release-3.6]).
  • Check all commits' messages are clear, describing what and why vs how.
  • Make sure to have added unit tests or integration tests to cover the new/modified code.
  • Check if documentation is impacted by this change.

Please review the guidelines for contributing and Pull Request Instructions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…0 to address CVE. Upgrade serverless_wsgi.py to the latest version. Changes to encoder, flask_app and etc. to adapt the version bump.
@hehe7318 hehe7318 requested review from a team as code owners August 6, 2025 21:48
@hehe7318 hehe7318 added the 3.x label Aug 6, 2025
@hehe7318 hehe7318 marked this pull request as draft August 6, 2025 21:48
@@ -108,7 +108,7 @@
"1",
]

if headers.get("Host", "").endswith(".amazonaws.com") and not strip_stage_path:
if "amazonaws.com" in headers.get("Host", "") and not strip_stage_path:

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
amazonaws.com
may be at an arbitrary position in the sanitized URL.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why changing this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

serverless_wsgi.py is a file we simply copy paste from https://github.com/logandk/serverless-wsgi/blob/master/serverless_wsgi.py.

@hehe7318 hehe7318 added the skip-bad-url-suffix-check Skip the checks regarding the bad URL suffix label Aug 7, 2025
@hehe7318 hehe7318 changed the title [Draft][develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to 3.1.3 to address CVE [develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to 3.1.3 to address CVE Aug 18, 2025
@hehe7318 hehe7318 changed the title [develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to 3.1.3 to address CVE [develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to 3.1.3 to address CVE-2024-34069 Aug 18, 2025
@hehe7318 hehe7318 changed the title [develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to 3.1.3 to address CVE-2024-34069 [develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to ~=3.0.0 to address CVE-2024-34069 Aug 18, 2025
@hehe7318 hehe7318 changed the title [develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to ~=3.0.0 to address CVE-2024-34069 [develop] Upgrade connexion to 2.15.0rc3, upgrade Werkzeug to >=3.0.3 to address CVE-2024-34069 Aug 18, 2025
@hehe7318 hehe7318 marked this pull request as ready for review August 18, 2025 20:35
@@ -108,7 +108,7 @@
"1",
]

if headers.get("Host", "").endswith(".amazonaws.com") and not strip_stage_path:
if "amazonaws.com" in headers.get("Host", "") and not strip_stage_path:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why changing this check?

CHANGELOG.md Outdated
@@ -31,6 +31,8 @@ CHANGELOG
- Upgrade DCGM to version 4.2.3 (from 3.3.6) for all OSs except AL2.
- Upgrade Python to 3.12.11 (from 3.12.8) for all OSs except AL2.
- Upgrade Intel MPI Library to 2021.16.0 (from 2021.13.1).
- Upgrade Connexion to ~=2.15.0rc3 (from ~=2.13.0).
- Upgrade Werkzeug to >=3.0.3 (from ~=2.0) in response to this [security risk](https://nvd.nist.gov/vuln/detail/cve-2024-34069).
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say "...to address CVE-2024-34069."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously there is one like:

  • Upgrade Python from 3.7.10 to 3.7.13 in response to this security risk.

But I am fine with both approach.

"jmespath~=0.10",
"jsii==1.85.0",
"werkzeug>=3.0.3",
"flask~=3.0",
"packaging~=25.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we need to add packaging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

packaging is in requirement.txt. I didn't add it. It was there but not in setup.py, so I added it here.


from pcluster.api.models.base_model_ import Model
from pcluster.utils import to_iso_timestr


class JSONEncoder(FlaskJSONEncoder):
class JSONEncoderForCli(json.JSONEncoder):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why ForCli? This encoder is used also by the API. Why not keeping the original class name?

"REQUEST_METHOD": event.get("httpMethod", {}),
"SCRIPT_NAME": script_name,
"SERVER_NAME": headers.get("Host", "lambda"),
"SERVER_PORT": headers.get("X-Forwarded-Port", "80"),
"SERVER_PORT": headers.get("X-Forwarded-Port", "443"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and below, why do we need to change the port and protocol?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

serverless_wsgi.py is a file we simply copy paste from https://github.com/logandk/serverless-wsgi/blob/master/serverless_wsgi.py. Don't know why.

@@ -217,15 +217,15 @@ def _run_operation(model, args, extra_args):
except Exception as e:
# format exception messages in the same manner as the api
message = pcluster.api.errors.exception_message(e)
error_encoded = encoder.JSONEncoder().encode(message)
error_encoded = encoder.JSONEncoderForCli().encode(message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to use the new Json encoder in entrypoint.py, but not in app.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not the new one, it's the old one actually. In connexion new v2 version(not 2.15.0rc3, but before it), the previous FlaskJSONEncoder was removed.
I renamed the two classes. Now it should be better.

cli/setup.py Outdated
"jmespath~=0.10",
"jsii==1.85.0",
"werkzeug>=3.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to accept only patch version upgrade (~=)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That means we can not get the 3.1.3 latest version. But you are right, we can not say werkzeug 4.0 in the future will not break our prod. I will do it in your way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Finally do ~=3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x skip-bad-url-suffix-check Skip the checks regarding the bad URL suffix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants