Phân tích phạm vi quyền của một policy
Mỗi quyền trên AWS được mô tả bằng một policy, tức một tài liệu JSON liệt kê action nào được phép hoặc bị từ chối trên resource nào; đọc được policy là kỹ năng cần có trước khi cấp quyền.
Trước khi gắn một policy do người khác soạn vào user hoặc role của MFTECH, cần xác định chính xác phạm vi quyền mà policy đó cấp. Chọn policy, dự đoán kết quả, sau đó gửi từng request để kiểm tra.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["ec2:RunInstances", "ec2:TerminateInstances"],
"Resource": "*",
"Condition": {
"IpAddress": { "aws:SourceIp": "203.0.113.0/24" }
}
}]
}Đọc policy bên trái, dự đoán kết quả, sau đó chọn một request để kiểm tra.
Đọc đúng policy mới là một nửa yêu cầu; nửa còn lại là cấp đúng và đủ quyền (least privilege). Nhóm tài chính của MFTECH cần liệt kê bucket mftech-reports và xoá báo cáo cũ, không hơn. Policy hiện tại chưa xoá được object. Chọn statement bổ sung và quan sát những request nào được phép.
{
"Version": "2012-10-17",
"Statement": [
{ "Effect": "Allow",
"Action": ["s3:ListBucket", "s3:DeleteObject"],
"Resource": "arn:aws:s3:::mftech-reports" }
]
}- CẦN · ALLOWLiệt kê báo cáo trong bucket
s3:ListBucket · mftech-reports - THIẾU · DENYXoá báo cáo cũ
s3:DeleteObject · mftech-reports/2026/10/sales.csv - DENYTải báo cáo xuống
s3:GetObject · mftech-reports/2026/10/sales.csv - DENYGhi đè báo cáo
s3:PutObject · mftech-reports/2026/10/sales.csv - DENYĐổi ACL của báo cáo
s3:PutObjectAcl · mftech-reports/2026/10/sales.csv - DENYXoá object ở bucket lưu trữ khác
s3:DeleteObject · mftech-reports-archive/2025/q4.csv
Thiếu 1 quyền cần thiết. s3:DeleteObject là thao tác trên object, nhưng Resource duy nhất là ARN của bucket. Không statement nào khớp request xoá object nên request bị từ chối ngầm định.
- Khi không có statement Allow nào khớp, request bị từ chối ngầm định (implicit deny). aws:SourceIp là địa chỉ IP của bên gửi request, aws:RequestedRegion là Region nhận API call.
- ListBucket áp dụng trên ARN của bucket, GetObject/DeleteObject áp dụng trên bucket/*.
- Wildcard trong tên action (
s3:*Object),s3:*và dấu*ở cuối ARN (bucket*, khớp cả/và bucket khác cùng tiền tố) đều dễ cấp thừa quyền.
Working out the permissions a policy grants
Every permission on AWS is described by a policy, a JSON document that lists which actions are allowed or denied on which resources; reading policies is a skill you need before granting access.
Before attaching a policy written by someone else to a MFTECH user or role, you must determine exactly what permissions it grants. Choose a policy, predict the result, then send each request to check.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["ec2:RunInstances", "ec2:TerminateInstances"],
"Resource": "*",
"Condition": {
"IpAddress": { "aws:SourceIp": "203.0.113.0/24" }
}
}]
}Đọc policy bên trái, dự đoán kết quả, sau đó chọn một request để kiểm tra.
Reading a policy correctly is half the job; the other half is granting exactly the permissions needed (least privilege). MFTECH’s finance team must list the mftech-reports bucket and delete old reports, nothing more. The current policy cannot delete objects yet. Choose the statement to add and watch which requests are allowed.
{
"Version": "2012-10-17",
"Statement": [
{ "Effect": "Allow",
"Action": ["s3:ListBucket", "s3:DeleteObject"],
"Resource": "arn:aws:s3:::mftech-reports" }
]
}- CẦN · ALLOWLiệt kê báo cáo trong bucket
s3:ListBucket · mftech-reports - THIẾU · DENYXoá báo cáo cũ
s3:DeleteObject · mftech-reports/2026/10/sales.csv - DENYTải báo cáo xuống
s3:GetObject · mftech-reports/2026/10/sales.csv - DENYGhi đè báo cáo
s3:PutObject · mftech-reports/2026/10/sales.csv - DENYĐổi ACL của báo cáo
s3:PutObjectAcl · mftech-reports/2026/10/sales.csv - DENYXoá object ở bucket lưu trữ khác
s3:DeleteObject · mftech-reports-archive/2025/q4.csv
Thiếu 1 quyền cần thiết. s3:DeleteObject là thao tác trên object, nhưng Resource duy nhất là ARN của bucket. Không statement nào khớp request xoá object nên request bị từ chối ngầm định.
- When no Allow statement matches, the request is implicitly denied (implicit deny). aws:SourceIp is the requester’s IP address; aws:RequestedRegion is the Region that receives the API call.
- ListBucket applies to the bucket ARN; GetObject/DeleteObject apply to bucket/*.
- A wildcard inside an action name (
s3:*Object),s3:*, and a trailing*in an ARN (bucket*, which also matches/and other buckets with the same prefix) all easily grant excess permissions.