tencent cloud

Cloud Access Management

ドキュメントCloud Access Management

Revoking Temporary Keys with a Deny Policy

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-11-25 17:50:54
AI翻訳

Scenarios

To promptly invalidate temporary keys (SecretId/SecretKey/Token issued by Security Token Service, STS) when they are suspected of being leaked, mistakenly distributed, or require emergency mitigation, you can attach an explicit Deny policy to the target sub-user or role so that temporary keys meeting specific time conditions are denied during authentication.
This document provides configuration instructions for the following three common invalidation methods:
Invalidate temporary keys generated at a specific time (accurate to the second).
Invalidate all temporary keys generated before a specified time.
Invalidate temporary keys generated within a specified time range.
Typical use cases:
Emergency mitigation: If a batch of temporary keys is suspected of being leaked, immediate blocking is required.
Accidental issuance recovery: If an automated task mistakenly issues temporary keys, the affected batch of temporary keys must be invalidated immediately.
Gray release rollback: Temporary keys generated within a specified time range become invalid, forcing the affected callers to obtain new keys.

Prerequisites

You have administrative permissions for CAM under the target root account, allowing you to create or edit custom policies and attach them to sub-users, user groups, or roles.
The generation time range of the temporary keys to be invalidated has been identified.
Note:
You can obtain detailed information about temporary keys by calling the GetFederationToken, or query key generation records through the CAM console.

Risk Warning

This method will cause all temporary keys generated by the specified sub-account UIN / role ID within the specified time range to fail authentication. If the same sub-account / role generates multiple temporary keys at the same time, these temporary keys will be rejected by CAM authentication simultaneously.

Core Mechanism Description

Explicit Deny has the highest priority: once a policy matches a Deny condition, the request is denied even if an Allow policy also exists.
Time comparison operators: CAM supports operators such as date_equal, date_not_equal, date_less_than, date_less_than_equal, date_greater_than, and date_greater_than_equal.
Time format requirement: Use the UTC ISO 8601 format, for example, 2026-03-02T05:32:55Z.

Important Notes

The example in this document uses qcs:token_create_time to represent the generation time of temporary keys.
Use action: ["*"] with caution: this configuration denies all operations across all cloud services, which may make sub-users completely unavailable in both the console and API. If you only need to restrict certain services, narrow down the action to specific service actions.
Select the associated entity based on how the key is obtained:
If the temporary key is obtained by assuming a role (AssumeRole), attach the Deny policy to that role.
If the temporary key is obtained by a sub-user calling GetFederationToken, attach the Deny policy to that sub-user.
Associating the wrong entity will cause the policy to not take effect. Make sure to confirm the source of the key.

Operation Steps

Step 1: Confirm the generation time and owner of the temporary key

Confirm the generation time of the temporary keys to be invalidated and the sub-user or role they belong to through the Security Token Service (STS) API or the CAM console.
Note:
Time conversion recommendation: Convert all times to UTC (with a trailing Z). For example, Beijing time (UTC+8) must be converted to UTC by subtracting 8 hours.

Step 2: Prepare the time condition for revocation

Prepare the corresponding time parameters based on the invalidation method you selected:
Invalidate before a specific time: Prepare the threshold time T.
Invalidate within a time range: Prepare the start time T_start and the end time T_end.
Invalidate at a specific time: Prepare the time T_exact accurate to the second.

Step 3: Create a custom policy

1. Log in to the CAM console using a root account or a sub-user with CAM administrative permissions.
2. Select Policies in the left sidebar to go to the Policy page.
3. Click Create Custom Policy > Create by Policy Syntax.
4. In the Select Template Type module, select Blank template, click Next, and go to the Edit Policy page.
5. Enter the following form:
Policy name: Define a unique and meaningful policy name, for example, deny-token-before-{time}.
Description: Optional. You can write a brief description, preferably indicating the purpose of the policy.
Policy content: Copy the policy content for the corresponding scenario from the policy examples below, and replace the time field as needed.
6. Click Complete, and then the policy is created.

Step 4: Attach the policy to the target entity

Note:
During emergency handling, bind precisely to the most clearly affected entity first to avoid expanding the impact scope.
1. Search for the policy you just created in the Policies, and click Authorize Users/Groups/Roles in the operation column on the right.
2. In the Authorize Users/Groups/Roles window, select the corresponding entity based on the key source:
Temporary keys obtained by assuming a role (AssumeRole) are attached to the corresponding role.
Temporary keys obtained by a sub-user calling GetFederationToken are attached to the corresponding sub-user.
It can also be attached to a user group for batch management.
3.Search for and select the target entity, and click OK to complete the association.

Step 5: Verify that the policy takes effect

Use the temporary key that is about to expire to initiate any TencentCloud API request or console operation.
Expected result: Authentication fails, and the request is rejected.

Policy Examples

The following examples are broad deny policies that block all operations. To reduce the impact scope, narrow down the action and resource fields.

1. Revocation of temporary keys generated at a specified time (accurate to the second) (recommended)

Goal: Revoke all operation permissions from all temporary keys whose generation time equals T_exact (accurate to the second).

{
"version": "2.0",
"statement": [
{
"effect": "deny",
"action": ["*"],
"resource": ["*"],
"condition": {
"date_equal": {
"qcs:token_create_time": "2026-03-02T05:32:55Z"
}
}
}
]
}


2. Revocation of all temporary keys generated before a specified time

Goal: Revoke all operation permissions from all temporary keys whose generation time is earlier than T.
{
"version": "2.0",
"statement": [
{
"effect": "deny",
"action": ["*"],
"resource": ["*"],
"condition": {
"date_less_than": {
"qcs:token_create_time": "2026-03-02T05:32:55Z"
}
}
}
]
}

Boundary description:
date_less_than means strictly less than. To also invalidate keys generated at or before T, use date_less_than_equal instead.

3. Revocation of temporary keys generated within a specified time range

Goal: Revoke all operation permissions from all temporary keys whose generation time is greater than or equal to T_start and less than T_end.
Note:
In this scenario, both boundaries must be placed in the condition of the same statement to express the logical relationship of "satisfying both conditions (AND)."
{
"version": "2.0",
"statement": [
{
"effect": "deny",
"action": ["*"],
"resource": ["*"],
"condition": {
"date_greater_than_equal": {
"qcs:token_create_time": "2026-03-02T05:00:00Z"
},
"date_less_than": {
"qcs:token_create_time": "2026-03-03T06:00:00Z"
}
}
}
]
}

Boundary description:
This notation represents a left-closed, right-open interval: [T_start, T_end).
To include the right boundary as well (a closed interval [T_start, T_end]), replace date_less_than with date_less_than_equal.

Supported Date Comparison Operators

Operator
Meaning
date_equal
Time equal to
date_not_equal
Time is not equal to a specified value.
date_greater_than
Time is greater than a specified value.
date_greater_than_equal
Time is greater than or equal to a specified value.
date_less_than
Time is less than a specified value.
date_less_than_equal
Time is less than or equal to a specified value.

Rollback Method

To restore access permissions for temporary keys, perform the following steps:
1. Log in to the CAM console.
2. Go to the corresponding management page based on the type of the principal associated with the policy:
To associate with a sub-user: go to the user list, find the target sub-user, and on the Permissions tab of the sub-user's details page, click Unbind next to the associated policy.
To associate with a user group: go to the user groups list, find the target user group, and on its details page, click Unbind next to the associated policy.
To associate with a role: go to Roles, find the target role, and on its details page, click Unbind next to the policy in the Authorized Policies section.
3. After you confirm the unbinding, the policy becomes invalid, and the temporary keys are restored to an accessible state.

FAQs

The policy is associated, but the temporary key is still usable?

Check the following items:
Whether the effect field of the policy is deny rather than allow.
Whether the policy is bound to the correct principal (keys obtained through AssumeRole must be bound to a role, and keys obtained through GetFederationToken must be bound to a sub-user).

Will the policy affect newly issued temporary keys?

It depends on the time condition settings in the policy:
Use the Expire Before a Specified Time method: as long as the threshold time T is earlier than the generation time of the new key, the new key is not affected.
Use the Time Range Expiration method: as long as the generation time of the new key is not within the range [T_start, T_end), the new key is not affected.
However, if the time conditions are configured improperly (for example, only a lower bound is set without an upper bound), the new key may also be rejected. Make sure to configure the time boundaries correctly.

Can I restrict only a specific product or API?

Yes. Narrow down the action from "*" to specific cloud service actions (for example, cos:GetObject), and narrow down the resource to specific resources as needed.
For detailed instructions, see Creating Custom Policy.

Associated Documents

If you want to learn how to obtain temporary keys, see GetFederationToken.
If you want to learn about CAM policy syntax, see Syntax Logic.
If you want to learn how to use condition keys, see Condition Keys and Condition Operators.
If you want to learn more about Security Token Service (STS), see Security Token Service Overview.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック