-
Notifications
You must be signed in to change notification settings - Fork 90
IAM | Block Accounts From Performing IAM API on Themselves #9328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IAM | Block Accounts From Performing IAM API on Themselves #9328
Conversation
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
WalkthroughA guard clause was added to the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3–5 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/util/account_util.js (1)
700-707: Self-IAM guard looks correct; confirm scope and consider using_check_root_accountThe new check correctly blocks root-like accounts (
owner === undefined) from performing IAM actions on themselves and returns the expectedNOT_AUTHORIZED+ “You do not have permission to perform this action.”, which matches the PR’s described behavior.Two minor follow-ups:
- This currently only blocks root accounts (and any account with
owner === undefined); IAM users (withownerdefined) can still call IAM APIs on themselves. Please confirm this is intentional and matches your threat model / UX expectations.- To avoid duplicating the “root account” condition, you could reuse the existing helper:
- requested_account = requesting_account; - // we do not allow for AWS account root user to perform IAM action on itself - if (requesting_account.owner === undefined) { + requested_account = requesting_account; + // we do not allow root accounts to perform IAM actions on themselves + if (_check_root_account(requesting_account) { throw new RpcError('NOT_AUTHORIZED', 'You do not have permission to perform this action.'); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/util/account_util.js(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.
📚 Learning: 2025-11-12T04:55:42.193Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.
Applied to files:
src/util/account_util.js
📚 Learning: 2025-11-19T15:03:42.260Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.
Applied to files:
src/util/account_util.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: run-package-lock-validation
- GitHub Check: run-jest-unit-tests
- GitHub Check: Build Noobaa Image
Describe the Problem
Currently, we didn't block accounts from performing the IAM API on themselves, the main issue it creates is that accounts can use the IAM API of access key i and delete their own access key.
Explain the Changes
Note: decide to leave the message of the error simple.
Issues:
Testing Instructions:
Note:
nbis an alias that runs the local operator frombuild/_output/bin(alias created bydevenv).kubectl wait --for=condition=available backingstore/noobaa-default-backing-store --timeout=6m -n test1kubectl port-forward -n test1 service/s3 12443:443kubectl port-forward -n test1 service/iam 14443:443alias account-1-iam='AWS_ACCESS_KEY=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:14443'account-1-iam iam list-users; echo $?admin-iam iam delete-access-key --access-key-id <access-key-of-admin>should fail.output:
Notes:
In step 1 - deploying the system, I used
--use-standalone-dbfor simplicity (fewer steps for the system in Ready status).I used the admin account, but for IAM operations, there is no difference between a created account and an admin account. I tested with the admin only because it saves steps (I have the admin account upon system creation and a bucket).
Doc added/updated
Tests added
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.