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

TLS 1.3: Fix anti replay fail from GnuTLS #6788

Merged

Conversation

yuhaoth
Copy link
Contributor

@yuhaoth yuhaoth commented Dec 15, 2022

Description

fix #6623

preceding-pr: #6891

ROOT CAUSE

TIME RESOLUTION OF TICKET AGE

The time precision of ticket_age is milliseconds(RFC 8446). But our precision is senconds, we caculate
ticket age with (mbedtls_time( NULL ) - ticket_recived)*1000 .
If the ticket is sent/received near the end of a second and client send ticket at the beggining of
next second, ticket age of client is 1000 ms, but ticket age of server is less than it. As a result,
it offends the anit replay ruler.

Workaround solution: Add 1 second to ticket_received and do reconnect 1 second later.

The issue can be reproduce and verified with #6712 . That PR include test script and test result.
This PR is to fix that.

  • Add platform time function with milliseconds.
  • Change the time resolution from seconds to milliseconds for ticket->start and ticket->ticket_received

The commit is come from #6712 and verified in that PR

Gatekeeper checklist

I am not sure if it needs backport.

  • changelog provided
  • backport not required
  • tests provided

Notes for the submitter

Please refer to the contributing guidelines, especially the
checklist for PR contributors.

@yuhaoth yuhaoth force-pushed the pr/fix-gnutls_anti_replay_fail branch 8 times, most recently from 0b842fc to 8edc501 Compare December 16, 2022 05:30
@yuhaoth yuhaoth added bug component-tls13 needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review priority-high High priority - will be reviewed soon labels Dec 16, 2022
@yuhaoth yuhaoth force-pushed the pr/fix-gnutls_anti_replay_fail branch 2 times, most recently from 4eb83db to 304fb38 Compare December 18, 2022 02:53
@yuhaoth yuhaoth force-pushed the pr/fix-gnutls_anti_replay_fail branch from 304fb38 to b62df4f Compare January 3, 2023 01:50
@yuhaoth yuhaoth force-pushed the pr/fix-gnutls_anti_replay_fail branch from 6eb846c to 0551d8d Compare January 4, 2023 03:03
@yuhaoth yuhaoth requested a review from xkqian January 4, 2023 12:06
@yuhaoth yuhaoth force-pushed the pr/fix-gnutls_anti_replay_fail branch from 0551d8d to 3717758 Compare January 7, 2023 08:28
@yuhaoth yuhaoth added needs-preceding-pr Requires another PR to be merged first and removed needs-reviewer This PR needs someone to pick it up for review labels Jan 7, 2023
@yuhaoth yuhaoth force-pushed the pr/fix-gnutls_anti_replay_fail branch 3 times, most recently from c9487a0 to 6da4268 Compare January 12, 2023 10:01
@yuhaoth yuhaoth force-pushed the pr/fix-gnutls_anti_replay_fail branch from 6da4268 to 30e2973 Compare February 3, 2023 03:19
The unit of ticket time has been changed to milliseconds.
And age difference might be negative

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Also add comments for age cast

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
- fix CI failure due to wrong usage of ticket_lifetime
- Improve document and comments

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Also add comments for age cast

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
- improve change log entry
- improve comments
- remove unnecessary statement
- change type of client_age

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
The output has been changed

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
@yuhaoth
Copy link
Contributor Author

yuhaoth commented Nov 21, 2023

Rebased to resolve conflicts

@yuhaoth yuhaoth requested a review from xkqian November 21, 2023 02:20
Copy link
Contributor

@xkqian xkqian left a comment

Choose a reason for hiding this comment

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

LGTM

@yuhaoth
Copy link
Contributor Author

yuhaoth commented Nov 21, 2023

internal CI reports pip install fail and open CI pass

Copy link
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

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

I've checked the rebase, LGTM.

@ronald-cron-arm ronald-cron-arm added this pull request to the merge queue Nov 21, 2023
@daverodgman daverodgman added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels Nov 21, 2023
Merged via the queue into Mbed-TLS:development with commit effdfe7 Nov 21, 2023
@yuhaoth yuhaoth deleted the pr/fix-gnutls_anti_replay_fail branch November 22, 2023 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-tls13 priority-high High priority - will be reviewed soon
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Early data test case will fail randomly cause the anti-play protection from gnutls server
5 participants