Key duration above i64::MAX seconds returns 500 instead of a duration error
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Read the key creation and duration validation flow for POST /api/v1/keys and the generate-key endpoint, then trace add_key_to_keys in the SQLite, PostgreSQL, and MySQL stores. Compare the clock validation with each store’s expiry conversion and review the #3051 spec PR context. Done means the chosen limit or error mapping returns a duration error for the reported overflow cases, including pre-generated keys.
Written by the indexing model from the issue text.
Description
Problem
An admin who sends a seconds_valid that makes the key's expiry (now plus the duration) exceed i64::MAX seconds while still fitting the clock (for example 9223372036854775808, 2^63; durations just below i64::MAX fail the same way, because the stores convert the expiry, not the duration) to POST /api/v1/keys or the generate-key endpoint gets 500 failed to add key instead of the 400 "invalid auth key duration" returned for values that overflow the clock. The clock check passes, then add_key_to_keys in the SQLite, PostgreSQL and MySQL stores converts the expiry with i64::try_from(value.as_secs()) and fails with Error::MalformedDatabaseRecord, which becomes PeerKeyError::DatabaseError and then AuthKeyError::Database. The pre-generated-key branch behaves the same way.
No panic is involved. This is a different root cause from #3051 (a persistence range limit, not the clock): the maximum expiry a key can have is decided by the database column type, but the request is validated only against the clock.
Open design question
Where the limit lives: bound the duration check by the largest expiry the stores accept (a shared constant), or map MalformedDatabaseRecord on insert to a duration error. To be decided in the spec.
Found by the automated review of the #3051 spec PR (torrust/torrust-tracker#3054).
- Dominant language
- Rust
- Stars
- 532
- Forks
- 56
- Avg merge
- 11h 20m
- Merged PRs (30d)
- 282
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from torrust/torrust-tracker
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
torrust/torrust-tracker#3080 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
torrust/torrust-tracker#3069 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
torrust/torrust-tracker#3058 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
torrust/torrust-tracker#2978 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
torrust/torrust-tracker#2332 ·
Maintainers usually reply within 1 day
All issues in torrust/torrust-tracker
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
difficulty: easy docs help wanted tooling
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
-
bug help wanted ui
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
userFRM/egui-charts#4386 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
eliasstravik/herdr-projects#1605 · 1 comment ·