Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lib/mbedtls: Update to mbedtls v3.6.2. #15547

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 1 commit into from
Jan 16, 2025

Conversation

gstrauss
Copy link
Contributor

@gstrauss gstrauss commented Jul 25, 2024

Summary

lib/mbedtls: Update to mbedtls v3.6.2 for security fixes

@gstrauss gstrauss marked this pull request as draft July 25, 2024 07:53
@gstrauss
Copy link
Contributor Author

converting to draft. probably need to update defines to pull build mbedtls with needed functions.

Copy link

github-actions bot commented Jul 25, 2024

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64: +1888 +0.223% standard[incl +64(data)]
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2: +2336 +0.256% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@gstrauss gstrauss force-pushed the mbedtls-3.6.0 branch 2 times, most recently from 5fdd5dd to 1dbca84 Compare July 25, 2024 08:20
@gstrauss
Copy link
Contributor Author

On unix port/* platforms: 1 tests failed: ssl_keycert
This weekend, I'll try to reproduce locally.

@projectgus
Copy link
Contributor

On unix port/* platforms: 1 tests failed: ssl_keycert

The fix for this failure is most likely here: #14385

@s-t-e-v-e-n-k
Copy link

Should probably change this PR to upgrade to 3.6.2 to fix another security issue -- https://nvd.nist.gov/vuln/detail/CVE-2024-49195

@projectgus
Copy link
Contributor

projectgus commented Oct 23, 2024

Should probably change this PR to upgrade to 3.6.2 to fix another security issue -- https://nvd.nist.gov/vuln/detail/CVE-2024-49195

Agree we should update, although this particular issue is in the mbedtls_pk_write_key_der() and mbedtls_pk_write_key_pem() functions which MicroPython doesn't use or expose. So I think this would only be an issue for a custom build that added C code to call these.

(To reiterate, we should still update all the same.)

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.58%. Comparing base (624bd48) to head (f2cd1a3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15547   +/-   ##
=======================================
  Coverage   98.58%   98.58%           
=======================================
  Files         167      167           
  Lines       21596    21596           
=======================================
  Hits        21291    21291           
  Misses        305      305           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gstrauss
Copy link
Contributor Author

#14385 was merged in Aug.

I rebased to tip of master and modified the mbedtls submodule to point to mbedtls 3.6.2 (changed from 3.6.0 originally set in this PR)

Two github CI tests fail:

In CI coverage_32bit test ("unix port / coverage_32bit (pull_request)"):
1 tests failed: thread_lock4
(which I believe is unrelated to the contents of this PR)

In CI annotations test ("Check commit message formatting / build (pull request)"):
there are error messages for commits which are not part of this PR. Perhaps the CI for annotations test should better handle determining changes in a force push by re-checking for changes against the base branch.

@gstrauss gstrauss changed the title lib/mbedtls: Update to mbedtls v3.6.0. lib/mbedtls: Update to mbedtls v3.6.2. Oct 24, 2024
@gstrauss gstrauss marked this pull request as ready for review October 24, 2024 04:48
@gstrauss
Copy link
Contributor Author

FYI: the coverage_32bit and thread_lock4 tests pass in CI on my branch
https://github.com/gstrauss/micropython/actions/runs/11492756466
I think that the thread_lock4 test might be racey with a false positive in the CI run here.

(On my branch, the CI "coverage" test failed due to me not having a token with appropriate permissions. That test passed in the most recent CI run here.)

@projectgus
Copy link
Contributor

projectgus commented Oct 24, 2024

Thanks for the update, @gstrauss!

In CI coverage_32bit test ("unix port / coverage_32bit (pull_request)"):
1 tests failed: thread_lock4
(which I believe is unrelated to the contents of this PR)

Yes, the thread tests are a tiny bit flaky on unix CI. I've retried and it passed.

In CI annotations test ("Check commit message formatting / build (pull request)"):
there are error messages for commits which are not part of this PR. Perhaps the CI for annotations test should better
handle determining changes in a force push by re-checking for changes against the base branch.
In CI annotations test ("Check commit message formatting / build (pull request)"):
there are error messages for commits which are not part of this PR. Perhaps the CI for annotations test should better > handle determining changes in a force push by re-checking for changes against the base branch.

Yeah, thanks for pointing this out. It's not the force push exactly, I think the bug is caused when the PR branch is behind the tip of master (your branch is one commit behind, from about the time you rebased so no fault of yours). Will submit a fix for the CI bug, but please don't stress about it for this PR.

The main thing with updating mbedTLS is on-device testing. I'll try to make time to do some soon.

@@ -79,6 +79,7 @@
#define MBEDTLS_OID_C
#define MBEDTLS_PKCS5_C
#define MBEDTLS_PK_C
#define MBEDTLS_PK_HAVE_ECC_KEYS
Copy link
Member

Choose a reason for hiding this comment

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

Is this enabling a feature that wasn't enabled before? Or is this needed to retain the same set of features with the new mbedTLS version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed to retain the same set of features with the new mbedTLS version

The latter. Some code moved to a new (separate) file with previously available features now exposed by a compile-time macro, as I noted in my second comment above (#15547 (comment))

projectgus added a commit to projectgus/micropython that referenced this pull request Oct 30, 2024
Fixes the problem noted here
micropython#15547 (comment)
which is that because default CI HEAD for a PR is a (generated) merge
commit into master branch HEAD, then if the PR branch isn't fully rebased
then the commit check runs against commits from master as well!

This PR also simplifies having to do a second fetch in order to find the
merge base, by passing it in from GitHub's metadata instead.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
projectgus added a commit to projectgus/micropython that referenced this pull request Oct 30, 2024
Fixes the problem noted here
micropython#15547 (comment)
which is that because default CI HEAD for a PR is a (generated) merge
commit into master branch HEAD, then if the PR branch isn't fully rebased
then the commit check runs against commits from master as well!

This PR also simplifies having to do a second fetch in order to find the
merge base, by passing it in from GitHub's metadata instead.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
projectgus added a commit to projectgus/micropython that referenced this pull request Oct 30, 2024
Fixes the problem noted here
micropython#15547 (comment)
which is that because default CI HEAD for a PR is a (generated) merge
commit into master branch HEAD, then if the PR branch isn't fully rebased
then the commit check runs against commits from master as well!

This PR also simplifies having to do a second fetch in order to find the
merge base, by passing it in from GitHub's metadata instead.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
projectgus added a commit to projectgus/micropython that referenced this pull request Oct 30, 2024
Fixes the problem noted here
micropython#15547 (comment)
which is that because default CI HEAD for a PR is a (generated) merge
commit into the master branch's current HEAD, then if the PR branch isn't
fully rebased then the commit check runs against commits from master as
well!

Also drops running this check on push, the pull_request event is triggered
by default on open and update ("synchronized" event), which probably covers
the cases where this check should run.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
projectgus added a commit to projectgus/micropython that referenced this pull request Oct 30, 2024
Fixes the problem noted here
micropython#15547 (comment)
which is that because default CI HEAD for a PR is a (generated) merge
commit into the master branch's current HEAD, then if the PR branch isn't
fully rebased then the commit check runs against commits from master as
well!

Also drops running this check on push, the pull_request event is triggered
by default on open and update ("synchronized" event), which probably covers
the cases where this check should run.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
dpgeorge pushed a commit to projectgus/micropython that referenced this pull request Oct 31, 2024
Fixes the problem noted at
micropython#15547 (comment)
which is that, because default CI HEAD for a PR is a (generated) merge
commit into the master branch's current HEAD, then if the PR branch isn't
fully rebased then the commit check runs against commits from master as
well!

Also drops running this check on push, the pull_request event is triggered
by default on open and update ("synchronized" event), which probably covers
the cases where this check should run.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
@projectgus projectgus self-requested a review November 20, 2024 03:21
Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

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

Thanks @gstrauss for submitting and updating this!

I rebased this branch and flashed to an RPI_PICO_W board. net_inet and multi_net tests all pass.

@projectgus projectgus modified the milestone: release-1.25.0 Jan 14, 2025
@projectgus
Copy link
Contributor

Oh, I also had a quick look at the code size increase. It looks like a significant part is the new bignum API. MicroPython doesn't call any bignum interfaces from what I can tell, but IIUC mbedTLS currently uses a mixture of the old and new bignum APIs internally - https://mbed-tls.readthedocs.io/en/latest/project/long-term-plans/#bignum-redesign - so this may drop down again in the future.

@projectgus projectgus added this to the release-1.26.0 milestone Jan 14, 2025
@dpgeorge
Copy link
Member

@projectgus should we put this in 1.25.0, or wait to 1.26.0? I'm happy either way, seems like a low risk change.

@projectgus
Copy link
Contributor

@projectgus should we put this in 1.25.0, or wait to 1.26.0? I'm happy either way, seems like a low risk change.

If you're happy to have it in 1.25.0 then it seems like a reasonable choice to me. I think there is some chance of an issue just due to all the APIs that are moving around, but agree it's pretty low risk - and good to be up to date with security fixes.

@dpgeorge
Copy link
Member

I tested this thoroughly on unix, PYBD_SF6, RPI_PICO2_W, running all possible combinations of WLAN tests against those three. Everything passes.

Let's merge this!

@dpgeorge dpgeorge merged commit f2cd1a3 into micropython:master Jan 16, 2025
62 checks passed
wiznet-grace pushed a commit to wiznet-grace/micropython that referenced this pull request Feb 27, 2025
Fixes the problem noted at
micropython#15547 (comment)
which is that, because default CI HEAD for a PR is a (generated) merge
commit into the master branch's current HEAD, then if the PR branch isn't
fully rebased then the commit check runs against commits from master as
well!

Also drops running this check on push, the pull_request event is triggered
by default on open and update ("synchronized" event), which probably covers
the cases where this check should run.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
wiznet-grace pushed a commit to WIZnet-ioNIC/WIZnet-ioNIC-micropython that referenced this pull request Feb 28, 2025
Fixes the problem noted at
micropython#15547 (comment)
which is that, because default CI HEAD for a PR is a (generated) merge
commit into the master branch's current HEAD, then if the PR branch isn't
fully rebased then the commit check runs against commits from master as
well!

Also drops running this check on push, the pull_request event is triggered
by default on open and update ("synchronized" event), which probably covers
the cases where this check should run.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
lawrencedudley pushed a commit to lawrencedudley/micropython-esp32-pcnt that referenced this pull request May 29, 2025
Fixes the problem noted at
micropython#15547 (comment)
which is that, because default CI HEAD for a PR is a (generated) merge
commit into the master branch's current HEAD, then if the PR branch isn't
fully rebased then the commit check runs against commits from master as
well!

Also drops running this check on push, the pull_request event is triggered
by default on open and update ("synchronized" event), which probably covers
the cases where this check should run.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
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.

4 participants