AccessToken omits `iat` claim despite documentation listing it

未关闭
#983 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@jay23606 已经在做这个了。

开始于 2026年10月27日。

  • #984 来自 @jay23606 —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
api, backend

调研方向

The report identifies AccessToken._generate_payload() and the base Jwt.payload property as the payload-generation entry points. Read those methods and the Access Token documentation to establish whether iat should be present, then inspect related tests. Done means the maintainers clarify the expected behavior and align the SDK or documentation, with a regression test if the SDK changes.

由索引模型根据 Issue 内容生成。

描述

type: bug
Describe the bug

In twilio-python version 9.12.0, an Access Token generated using AccessToken and SyncGrant does not contain the iat (issued-at) claim.

I inspected the generated JWT payload and the installed SDK source code. The payload contains jti, iss, sub, nbf, exp, and grants, but no iat.

However, Twilio's documentation lists iat among the claims expected in a correctly formed Access Token.

Could the maintainers clarify whether this omission is intentional, and whether the SDK or documentation should be updated for consistency?

I have not demonstrated an authentication or authorization failure. This report is intended to clarify the observed behavior rather than claim a security vulnerability.

Code snippet
import os
import json
import base64

from twilio.jwt.access_token import AccessToken
from twilio.jwt.access_token.grants import SyncGrant

account_sid = os.environ["TWILIO_ACCOUNT_SID"]
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_KEY_SECRET"]
service_sid = os.environ["SYNC_SERVICE_SID"]

token = AccessToken(
    account_sid,
    api_key,
    api_secret,
    identity="bb-test-identity",
    ttl=600,
)

token.add_grant(SyncGrant(service_sid=service_sid))
jwt = token.to_jwt()

if isinstance(jwt, bytes):
    jwt = jwt.decode("utf-8")

payload_part = jwt.split(".")[1]
payload_part += "=" * (-len(payload_part) % 4)
payload = json.loads(base64.urlsafe_b64decode(payload_part))

print("Payload claim names:", sorted(payload.keys()))
print("iat present:", "iat" in payload)
Actual behavior

With twilio-python 9.12.0, the generated Access Token payload did not include iat.

The inspected source shows that AccessToken._generate_payload() adds jti and grants, while the base Jwt.payload property adds iss and exp, and conditionally adds nbf and sub. Neither method explicitly adds iat.

My local Sync tests otherwise behaved as expected: permitted reads succeeded, and unauthorized reads and writes were rejected.

Expected behavior

I expected the SDK's behavior to be consistent with the published Access Token documentation, which describes iat as the token's issue timestamp.

If iat is required, the SDK should include it in the generated payload. If it is optional, the documentation should clarify this distinction.

References:

twilio-python version

9.12.0

Python version

3.14.7

Logs or error messages

No authentication error observed. The issue was identified by inspecting the generated JWT payload and the installed SDK source code. The token payload did not contain an iat claim.

Additional context

Environment: Kali Linux under WSL, using a Python virtual environment.

The Sync service had ACLs enabled. Tests using authorized and unauthorized test identities behaved as expected.

I also inspected the installed SDK's JWT payload-generation methods and found no explicit iat claim generation in those methods.

I have not established a security impact or confirmed that Twilio rejects these tokens. I am requesting clarification about whether this is intentional SDK behavior or a documentation inconsistency.

Could the maintainers clarify the expected behavior and, if appropriate, add a regression test?

主要语言
Python
星标
2.1k
派生
821
平均合并
9 小时 33 分钟
30 天内合并 PR
3

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

twilio/twilio-python 的其他 Issue

查看 twilio/twilio-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。