`isExpired` doesn't correctly validate `iat`
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
調査の方向性
lib/src/main/java/com/auth0/android/jwt/JWT.java の 161~171 行付近から始め、isExpired が時間の境界を計算して iat を検証している箇所を確認します。作成直後に使用された JWT で報告されたケースを再現し、その後、既存の leeway や有効期限チェックを弱めることなく、有効な iat が受け入れられることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Checklist
- I have looked into the Readme and Examples, and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
Due to the way the isExpired was implemented, the iat is invalid for the first 0.5 seconds of JWT existence, given this code here:
The line 165 is rounding the current time. If your server is very fast and generate, transmit and reaches your application in less than 0.5s, the futureToday.before(payload.iat) on the line 169 returns false. But the JWT is totally valid.
Solutions:
- Also compare
futureToday == payload.iat. - Stop truncating the
todayTime.
I reimplemented the validation in Kotlin and added some logs:
fun isExpired(jwt: JWT, leeway: Int): Boolean {
val todayTime = (floor((Date().time / 1000).toDouble()) * 1000).toLong() //truncate millis
val futureToday = Date(todayTime + leeway * 1000)
val pastToday = Date(todayTime - leeway * 1000)
val expValid = jwt.expiresAt == null || !pastToday.after(jwt.expiresAt)
val iatValid = jwt.issuedAt == null || !futureToday.before(jwt.issuedAt)
return !expValid || !iatValid
}
This prints:
todayTime 1740576730000
futureToday 1740576730000
pastToday 1740576730000
expValid true
iatValid false
Reproduction
Probably create the JWT and use it straightway, it will fail on the iat.
Additional context
No response
JWTDecode.Android version
2.0.2
Android version(s)
API 32
- 主要言語
- Java
- スター
- 457
- フォーク
- 81
- 平均マージ
- 5時間 4分
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
auth0/JWTDecode.Android のほかの issue
-
feature request
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
auth0/JWTDecode.Android#82 · リアクション 10 件 ·
-
Include proguard consumer directives for R8 compatibility再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンfeature request
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
auth0/JWTDecode.Android#72 · コメント 7 件 · リアクション 3 件 ·
auth0/JWTDecode.Android の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
scylladb/scylla-cdc-source-connector#350 ·
メンテナーはふだん 1 日以内に返信
-
agent:working documentation enhancement go:build lane:needs-decision
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Sanne/incus-spawn#1435 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
area:shuffle bug priority:high requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion-comet#7062 ·
メンテナーはふだん 1 日以内に返信
-
wait for review
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue up-for-grabs
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
AnikethTS/ChangeRadar#22 ·
メンテナーはふだん 1 日以内に返信