mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 23:29:28 -05:00
fee688bd051a5bde4e2e8a4d5e0f5d75c7ffe00a
22
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
34269655ba |
feat(sts): read every modelled operation's constraints from the model (#6925)
The seven operations that still answered an absent member from a check of their own are read against the vendored shapes now, which leaves every STS operation that models a member reading its constraints from the model: `AssumeRole`, `AssumeRoleWithSAML`, `AssumeRoleWithWebIdentity`, `AssumeRoot`, `DecodeAuthorizationMessage`, `GetDelegatedAccessToken` and `GetFederationToken`. `GetCallerIdentity` carries no member, so there is nothing to read for it. Two answers move, both onto the form the model and the rest of this package give. A member the request leaves out is named as a constraint message spells it, `roleSessionName` rather than `RoleSessionName`, and every absent member is reported together in the order the model lists them, where the check it replaces answered the first it found. A member sent empty is a value the request carries, so it breaks its own minimum length rather than reading as absent. That is the reading #6811 settled for the two services and what `validateRequired` was the last of in this handler. What the seven gain is every bound beside the required members, none of which was read at all: `RoleArn` at 20 to 2048 characters, `RoleSessionName` at 2 to 64, `ExternalId`, `SourceIdentity`, `SerialNumber`, `TokenCode`, `Policy`, `PolicyArns`, `Tags`, `TransitiveTagKeys` and `ProvidedContexts` on `AssumeRole`, `SAMLAssertion` at 4 to 100000, `WebIdentityToken` at 4 to 20000, `ProviderId` at 4 to 2048, `Name` at 2 to 32, `EncodedMessage` at 1 to 10240, and the `DurationSeconds` and `MinimumSessionTokenSize` ranges each operation declares. `AssumeRoot`'s own length check on `TargetPrincipal` said what the model says, so it comes off with the rest. One reading is this emulator's own, and `docs/services/sts.md` says so. `TradeInToken` is required and declares no length, so a request sending it empty carries a value: it reaches the lookup and is answered `ExpiredTradeInTokenException`, the refusal any token that cannot be redeemed gets, where the check it replaces called it absent. Nothing published says what AWS answers an empty trade-in token. Each operation keeps the refusals it answers ahead of the constraints: `GetFederationToken` and `GetSessionToken` turn away session credentials first, and `AssumeRoot` refuses the global endpoint first. Three test fixtures carried values AWS refuses and now carry values it takes. A `RoleSessionName` of `s` is one character where the model declares two, and a `WebIdentityToken` of `jwt` three where it declares four, so the fixtures that sent them are a character longer, as are the two assertions that read a session name back out of an assumed-role ARN and a condition key. The name the shared role-session fixture opens under has one writer now, `EnforcementFixtures.SESSION_NAME`, read by every test asserting on that session rather than spelled again in each: an `aws:userid` condition, a `PrincipalArn` condition, two authorization-denial messages and the ARN two trust-policy cases read back. Each of those carried the one-character name, which is a 403 where the case wants a 200, or a prefix match that no longer pins the whole ARN. |
||
|
|
c9c1c0990b |
feat(sts): read a Query request's declared constraints from the model (#6891)
`GetAccessKeyInfo`, `GetSessionToken` and `GetWebIdentityToken` are held to the constraints botocore's STS model declares, which `tools/aws/regen_sts_shapes.py` vendors into `aws/sts-request-shapes.json` and `StsRequestShapes` reads through the same `QueryConstraintCheck` walk IAM reads its own file with. The two services share the protocol, the message wording and the generator, so what is new is which operations are read rather than how. What it adds is on `GetSessionToken`: `SerialNumber`, `TokenCode` and `MinimumSessionTokenSize` are declared and nothing read them, so a serial number under 9 characters, a token code that is not six digits and a size past 4096 answer `ValidationError` where they answered credentials. The size is still only validated, the token staying the length this emulator mints. `GetAccessKeyInfo` and `GetWebIdentityToken` keep the messages they already answered, from the same bounds and the same patterns, and about 130 lines of hand-written audience, tag and access-key checks come out. One answer moves: a value breaking two constraints is answered for both, where the if-else chain stopped at the first. That is the reading #6402 settled and #6580 already took for an empty role name. `jwtAlgorithmType` publishes a fixed length of 5 and no enum, the two values coming from the reference, so the walk takes a documented constraint keyed by member name and reports it in that member's place, which keeps a collected message in the model's order. It is reported only for a member the request carries that breaks nothing the model declares, which is the exclusivity the hand-written helper had. A value that is no number at all stays `InvalidParameterValue`, answered before the constraints, since the model declares a range and says nothing about what counts as a number; a digit string is a number of any width, so a `DurationSeconds` of `99999999999` breaks the maximum rather than being called no integer, as #6625 settled for an oversized `MaxItems`. Each operation asks for its violations where its own check ran rather than ahead of the switch, because `GetSessionToken` refuses session credentials before it reads anything. The whitespace around a number comes off wherever this handler reads one. The check takes a padded value and holds it to its range, so the read behind it parses the same text: parsing the value as the request spelled it threw there and fell back to the default, so a ` 3600 ` asking for an hour would have been handed the twelve hours `GetSessionToken` defaults to, or the five minutes a web identity token defaults to. IAM reads its own `MaxItems` that way already. The generator is not new code. `request_shapes.main` already drives the five generators that vendor member types, so it takes an `operations` argument now and both Query-protocol generators hand it their model, output and operations the same two-line way, which takes the hand-rolled driver out of `regen_iam_shapes.py` as well. ECR and Resource Groups still carry theirs and are a refactor of their own. The generator contract tests move with it: that a vendored file carries exactly the operations its generator lists and resolves every shape it names is one parametrized test over all four constraints generators rather than a copy per generator, and `build_constraints`'s own properties are tested once, where the shared module already tested them. The model transform the driver takes is driven through it as well, the file it writes carrying what the transform left and the staleness check calling that file current only when it prepares the model the same way, and IAM's own tests read the vendored file for each paged request reduced. Three sentences this handler wrote out by hand go the same way. The two range refusals and the length refusal on `TargetPrincipal` come from `SmithyValidationErrors`, which already wrote them word for word, and the "Must be an integer." refusal has one writer and three callers. The length comparison counts code points rather than UTF-16 units as a result, which is the reading the rest of the package uses. |
||
|
|
4c55ec6b77 |
feat(sts): vend a signed web identity token for the calling identity (#6517)
GetWebIdentityToken is the last operation the pinned STS model publishes and Floci did not dispatch, which takes STS to 11 of 11. It answers "a signed JSON Web Token (JWT) that represents the calling Amazon Web Services identity", signed by STS and verifiable against the keys the issuer publishes. The issuer is IAM's. Outbound web identity federation mints one issuer URL per account, so the token names it as iss and the operation reads the switch behind it: while the feature is off the answer is OutboundWebIdentityFederationDisabledException, not the FeatureDisabled the IAM getter answers. SessionDurationEscalationException is the other refusal with a published trigger, for a caller on temporary credentials asking for a token that would outlive its own session, "beyond what was granted when the session was originally created". JWTPayloadSizeExceededException is modelled and nothing published says what the maximum payload is, so no size is invented here to refuse a request with. A temporary credential with no live session behind it is refused as expired rather than read as a caller that cannot be identified. IamEnforcementFilter answers ExpiredTokenException for one and it never reaches the operation, but with enforcement off, or in the window between that check and this one, the session lookup comes back empty and the caller would fall to the account root ARN this file hands an unresolvable caller, as GetCallerIdentity does. A token is not a request: its subject is signed and outlives the call, so a session already gone does not get one that speaks for the account, while an unknown long-term key keeps the stand-in. The filter's wording is shared rather than copied a second time. The declared constraints are read ahead of all of it, as #6402 put them elsewhere in this package: Audience required and 1 to 10 members of 1 to 1000 characters, SigningAlgorithm required at a fixed length of 5, DurationSeconds 60 to 3600 defaulting to 300, and Tags at most 50 with its keys and values held to their own lengths and pattern. A member sent empty is a member that is present, breaking its length rather than reading as absent, and a list member's violation names the index the request sent rather than the number it reads as, which is what #6478 settled. The claim layout is the IAM User Guide's. The standard OIDC claims sit at the top level, iss, aud, sub, iat, exp and jti, with the caller's ARN as the subject, and the custom claims are nested under the https://sts.amazonaws.com/ namespace the guide names: aws_account for the account the token was asked for, source_region for the region it was asked from, and the request's tags under request_tags. "All these claims may not be present in a token at the same time", so the organization, principal tag and session context claims the guide also lists are left out rather than invented, and request_tags is absent from a token whose request named none. The nesting is also what keeps a tag off a claim STS sets, a tag named exp being a key under request_tags rather than the claim that chooses the token's lifetime. Two answers are readings and docs/services/sts.md says so. The model publishes no enum for SigningAlgorithm, only the fixed length, so a five-character value that is neither RS256 nor ES384 is answered with this package's enum violation over the two values the reference names. The global endpoint refusal borrows the wording AWS publishes for AssumeRoot, the note for this operation giving none of its own. Signing goes through a new core.common helper rather than a third copy of the assembly: Cognito and EKS each already sign a JWT, and EksOidcService moves onto it here. ES384 signs through the JDK's P1363 variant, so the signature is the raw R || S pair JWS defines rather than the DER sequence a default ECDSA signer returns. Each account's key is minted on first use per algorithm and stored, so a restart does not invalidate a token already handed out. Eleven tests over the wire, including the claim set with the namespaced account and region, both signature shapes by their exact lengths, the tags arriving under request_tags rather than as claims of their own, the ceiling the caller's own session puts on a token, the refusal for a session already gone, and the constraints read while the feature is off. Beside them, a unit test verifies a minted token against the public half of the stored key for both algorithms, a length being no evidence of what was signed, and holds that one token's signature does not verify over another's claims; and the handler test takes the session ceiling to its own boundary on a fixed clock, where a token ending exactly with the session is issued, one ending a second later is refused, and nothing is minted on the refusal. What is not here is the other half: nothing publishes the verification key yet, so the discovery documents the issuer URL would host are not served, and the docs say that plainly. |
||
|
|
b4c71b9e25 |
fix(iam): authorize sts:AssumeRole against the role it names (#6334)
IAM enforcement evaluated every STS action against resource *, so a policy allowing sts:AssumeRole on specific role ARNs never matched and the call was denied. sts:AssumeRole is now authorized against the request's RoleArn, as on AWS. Every other STS action stays at *: like Logs and Secrets Manager, the resource follows the serving operation, so a RoleArn added to a call that never reads it, such as GetFederationToken, cannot make a role-scoped Allow grant that call. Query-protocol parameters were only read from the URL, never from the form body the SDKs and CLI POST, so SQS and SNS resource ARNs fell back to a wildcard the same way. For a form POST they are now read from the body alone: AwsQueryController dispatches on the body and never sees the URL query, so authorizing a URL value would check one resource and act on another. SQS preferred a QueueUrl in the URL over the body's, so it now reads the body first as well. A resource field with an invalid percent escape is read as absent, so the check falls back to the default resource instead of throwing out of the filter; the request then fails in the form reader exactly as it does without the resource check. The RoleArn is checked untrimmed, as the handler uses it. docs/services/sts.md no longer lists the * check as a known limitation. Co-authored-by: Robin Baeckman <27041454+RobinBaeckman@users.noreply.github.com> |
||
|
|
c094ce3973 |
feat(sts): dispatch AssumeRoot and authorize centralized root access (#6251)
Floci dispatched the five operations that turn centralized root access on and off and nothing that uses it, so the feature was half emulated: AssumeRoot, the operation they exist for, answered UnsupportedOperation. The five took no caller check of their own either, so any account could enable or disable organization wide root features, and the record they wrote was scoped to the calling account, which left the management account's toggle invisible to a delegated administrator. All five answer for one organization now, so all five check the caller, and each refusal is a shape the reference models on them and on nothing else: no organization is OrganizationNotFound, one without All features is OrganizationNotInAllFeaturesMode, one without trusted access for IAM is ServiceAccessNotEnabled, and a caller that is neither the management account nor a delegated administrator is AccountNotManagementOrDelegatedAdministrator. The two enable operations add CallerIsNotManagementAccount, modeled on them alone, so a delegated administrator may read the features and turn them off but not on. The feature set belongs to the organization, so it is read and written in the management account's scope whoever asks, and the OrganizationId the model declares beside EnabledFeatures is answered now that the organization is known. Organizations answers all of this through a provider interface in the iam package, the way ScpProvider already does, so IAM still does not depend on it. AssumeRoot opens the session those features allow. It acts as the member account's root user, which no identity policy grants or denies, scoped by the TaskPolicyArn the request names: the five AWS managed policies the model names, under the root-task path, each denying everything it does not name, so the policy is the whole of the bound and is read beside the root's own allow-all rather than as a session policy with nothing to allow. A customer- managed policy can carry that path too and is refused, being the caller's own document rather than one of AWS's. The caller must be able to manage root access and have RootSessions enabled, the target must be a member account other than the management account, and the audit reads those policies allow name the member account's root user when they carry no UserName, which is what their own arn:aws:iam::*:root asks for. What is chosen rather than read is documented in docs/services/sts.md: the operation models only RegionDisabled and ExpiredToken, so every caller, target and feature refusal is AccessDenied 403 and a task policy outside the root-task path is a ValidationError, the shape MinimumSessionTokenSize also answers outside the 0 to 4096 the model declares for it, the size asked for being the size issued. The guide's refusal of root user credentials covers both credentials this emulator reads as the account root, one that resolves to a root ARN and the bare account-id key the enforcement filter calls floci's account-root principal, so a privileged session is opened by an IAM user or role of the management account as it is on AWS. The global endpoint is refused when the request arrives on that host, which is the only way a request says so. |
||
|
|
4eea01741f |
feat(sts): dispatch GetAccessKeyInfo, the account an access key id belongs to (#6121)
GetAccessKeyInfo answered UnsupportedOperation 400. It takes one member and answers one: "when you pass an access key ID to this operation, it returns the ID of the AWS account to which the keys belong", and it models no errors at all, so the whole operation is that lookup plus the shape of its input. The lookup is not the one authentication uses. resolveAccountId takes only an active long-term key and a live session, because that is what a request may be signed with, where this operation is explicit about the opposite: "this operation does not indicate the state of the access key. The key might be active, inactive, or deleted". So findAccountForAccessKeyId answers from what is stored whatever state it is in, a long-term key through the account that holds it and an ASIA key through the session that minted it, which is the split the page draws between AKIA as "long-term credentials for an IAM user or the AWS account root user" and ASIA as "temporary credentials that are created using AWS STS operations". Both long-term lookups read one scan now, the authentication one keeping the Active filter over what the new one answers whole, so the guard and the scan are written once. The id is read against accessKeyIdType first, 16 to 128 characters of [\w], which the reference glosses as "any upper- or lowercase letter or digit", so a malformed id answers for its own shape rather than for a key that could not exist. The violation is rendered the way the one recorded IAM rendering Floci already follows renders it, the member in lower camel case and the offending value quoted beside it; the older STS operations name the parameter as written instead, which is drift of its own rather than something to copy here. An absent member and a present empty one are different answers as well: only the absent one reads as null, where AccessKeyId= is a value that fails the minimum and is quoted as the empty string it is, which is what IAM answers for an empty RoleName over this same wire. One answer is chosen rather than read. The operation models no error for a key that is not there, and the page says only that "providing a deleted access key might return an error that the key doesn't exist", so a well-formed id this emulator never issued answers InvalidParameterValue, the published common error closest to that sentence. docs/services/sts.md records it as a deviation rather than a recorded behaviour, since nothing says what AWS answers for an id it never issued. Enforcement is untouched on purpose. The "No permissions are required" note appears on GetCallerIdentity and GetSessionToken and on no other page in the reference, and sts:GetAccessKeyInfo is in the service authorization reference, so this one is authorized like any other action rather than exempted the way GetCallerIdentity is. Ten tests. Five over the wire: a long-term key answering the account that holds it, an inactive key still answering it, a session key answering the account its session belongs to, four shapes refused ahead of any lookup, and a well-formed id nobody holds. Five on the handler: the account answered and the authentication path not consulted, the absent, short, long and malformed ids, a present blank id read as a value rather than an absence, and the refusal for a key the service does not hold. Docs carry the action, a section on what it does and does not say about the key, and the matrix row at 9. |
||
|
|
494a6725a1 |
feat(iam): release and exchange the delegation token (#5914)
M4a dispatched the delegation request lifecycle as far as ACCEPTED and stopped there, so no request reached FINALIZED and the credentials the whole feature exists to hand over could not be obtained at all. This is the token half: IAM SendDelegationToken and STS GetDelegatedAccessToken, the last two of the ten operations the family spans. SendDelegationToken takes a request id, answers no output shape, and moves an ACCEPTED request to FINALIZED. The reference says that "cannot be rolled back", which makes it the one transition that refuses to repeat itself: releasing twice answers ConcurrentModification, the wrong-state shape the other four writers already use. Releasing mints the token and records the instant it happened, both on the request, because the shape publishes neither and nothing else is going to hold them. Releasing is also where OnlySendByOwner is finally read. M4a stored the flag with nothing looking at it, which was right while nothing could release; SendDelegationToken is the one operation it speaks to. It "prevents any party other than the owner from calling SendDelegationToken API for this delegation request", for the case the reference spells out: the owner lacked the permission to approve, forwarded the request to a more privileged user, and still has to be the one who hands the token over. So the release is the one call on this family decided per identity rather than per account, the handler passing the caller ARN as associate and accept already do, and an approver who is not the owner answers AccessDenied 403, which the API reference publishes as a common error for every IAM operation. GetDelegatedAccessToken exchanges that token for credentials in the customer's account. The delegation period "starts when customer releases the exchange token, not when the product provider redeems it", and "all credentials obtained from the same exchange token expire at the same time", so the expiry is release plus SessionDuration whenever it is redeemed and a token can be exchanged repeatedly, each exchange buying less time than the one before. AssumedPrincipal is the identity that approved the request rather than the one that claimed it: accepting a request "records the details and the state of the identity that called this API", and "this is the identity that gets mapped to the delegated credential", which the user guide says the same way, the provider obtaining the "approver's temporary credentials". The two are the same identity until a request is forwarded for approval, which is the case OnlySendByOwner serves. PackedPolicySize is left out: the model deprecates it and states it is not populated for this operation. Two answers had to be chosen rather than read off, both forced by the error set. GetDelegatedAccessToken models exactly three errors, and none of them says "no such token", so a token nothing matches is answered as an expired one: from the caller's side the two are the same situation, and the reference's own remedy, "Request a new token and retry the operation", fits both. A token offered by an account that did not file the request answers AccessDenied 403 instead, the shape this handler already uses for a caller who may not perform the operation, because "the exchange token can only be redeemed by the product provider account that created the delegation request" is a refusal rather than an expiry. The account is checked before the window so that neither guard can hide the other, and both are tested with the other one passing. The code is ExpiredTradeInTokenException, not ExpiredTradeInToken. The model writes the Exception suffix into error.code for that shape and for RegionDisabledException while PackedPolicyTooLarge drops it, so each code is read off its own shape rather than derived from the shape's name. What the credentials carry is the request's PermissionPolicy, the policy AWS renders from the partner's registered template. No API registers a template, so nothing sets it and the session carries none, which is where M4a left PolicyTemplateArn for the same reason. The session is filed in the customer's account with no issuing key, and as a delegated session rather than an issued one. The delegation is the customer's grant, so a partner key that happened to name an IAM user must not become the session's issuer: issuingUser bounds a session by the issuer's own permissions, which would be the partner's rather than what the customer gave away. The approver is carried in a field of its own for the same reason the issuer is left empty. An issued session holds its identity in the role ARN slot, which is resolved by name, so an approver named like a role would act with that role's permissions, one named like no role would act with none, and GetCallerIdentity would answer for a role that does not exist. A delegated session instead resolves its approver from what the ARN says it is: a user's own policies and boundary, the account's access where the root approved the request, the role behind a session assumed from one, and nothing where that identity is gone. The account is the owner's either way, a request being visible only from the account that claimed it. The request's PermissionPolicy still bounds it on top wherever one exists, which is where the registered template would land. One gap this step cannot close on its own. AWS publishes the exchange token only in the ExchangeToken notification on the partner's SNS topic, and no operation on the family answers it. Floci sends no notification yet, so the token is minted onto the record and nothing hands it back over the wire. The integration test reads it from the service for that one step and drives everything either side of it over the wire. Twenty-one tests: eight on the service covering the release, the owner-only flag either way, the repeated exchange, both refusals and the window, with a clock the test owns, eight over the wire across the two accounts, one on the handler holding the session to the customer's account and to its approver, and four under IAM enforcement on what the credentials may then do: an approver allowed to read and not write, whose delegated credentials do exactly that, a request forwarded to an administrator who approved it, whose credentials write where its owner can only read, a role carrying the approver's name that lends them nothing, and a request approved by the account root. Four probes, each reverting one thing: mapping the credentials to the owner fails the forwarded case and the handler test and nothing else, anchoring the expiry at the redemption instant fails the two tests that describe it, filing the session against the partner fails the one that holds it, and dropping the owner-only guard fails the one that asks for it. SendDelegationToken joins the delegation family in ResourceArnBuilder, AWS giving it the delegation-request type, so it is authorized against the request rather than the wildcard. Routing needs nothing added since #5879 reads each service's actions from its botocore model, which names both of these, so the matrix rows in docs/services/index.md are the only counts this moves: IAM 174 to 175 and STS 7 to 8. |
||
|
|
c907eec9d2 |
fix(sts): require long-term callers for federation tokens (#5586)
* fix(sts): require long-term callers for federation tokens * fix(sts): preserve temporary federation caller refusals * fix(sts): refuse temporary federation callers before dispatch |
||
|
|
a017c94ecc |
fix(auth): verify query signatures and retain STS caller identity (#5584)
* fix(sts): retain caller identity for query credentials * fix(sts): retain form token precedence for caller identity * docs(sts): clarify credential header precedence * fix(sts): verify presigned caller identity requests * test(sts): respect the configured signature-checking mode * fix(auth): verify query signatures across services |
||
|
|
43eacd524c |
fix(sts): reject session-token requests from temporary callers (#5582)
* fix(sts): reject session-token requests from temporary callers * fix(sts): retain query callers with blank authorization headers |
||
|
|
a3118eb42b |
fix(sts): evaluate GetSessionToken and GetFederationToken sessions as the user that minted them (#5081)
Under IAM enforcement, credentials from the two STS operations that mint a session from a long-term key were evaluated as the wrong identity: - A GetSessionToken session was stored with no role ARN, which resolveCallerContext answered with null, and the enforcement filter lets a known credential it cannot map to policies through. A user allowed only sts:GetSessionToken got credentials that passed every check, IAM calls included, and since the session had no caller ARN, AssumeRole took it for the account root and let it assume any role whose trust policy names the account. AppSync's IAM authorization and RDS IAM database authentication also read a null context as allowed, so they let these sessions through too. - A GetFederationToken session was stored with the federated user's ARN where a role session keeps its role's, and its permissions were read from the role whose name followed the last slash. A user allowed only sts:GetFederationToken that federated under an existing role's name got that role's permissions; any other name got none, even with a session policy. The STS API Reference says GetSessionToken credentials "have the same permissions as the IAM user", and that a GetFederationToken session with no session policy "has no permissions", and otherwise the intersection of "the IAM user policies and the session policies". Both handlers now record the identity whose key signed the request. An active key of a user in the request's account names that user, by ARN and unique ID. A key no account holds, the legacy test key or the account id among them, names the account root, which is how Floci already treats such a key. A GetSessionToken session is evaluated as that user, policies and boundary included, or as the root, whose context the filter still bounds by the account's service control policies. A federated session is evaluated as that user intersected with its session policy. Without one it has no permissions of its own, but keeps the Deny statements of its user's policies and boundary: a resource policy naming the federated user grants to the session past implicit denies, not past explicit ones (IAM User Guide, "Resource-based policies for AWS STS federated user principal sessions"). Whatever its policies allow, a federated session cannot call any IAM operation, nor any STS operation except GetCallerIdentity (STS API Reference, GetFederationToken), so its context always carries an explicit Deny for iam:* and sts:*; the filter answers GetCallerIdentity before reading any policy. A session whose issuer is gone is no credential at all, refused like an unknown access key, so neither a resource policy nor S3's fallback to the account root acts on its behalf. That covers a session minted with any other key IAM holds (another session's, which AWS does not accept here, or an inactive key or another account's, which account routing can land in the default account), a session whose user was deleted and recreated under the same name, and one stored before the issuer was recorded. The caller identity follows: a GetSessionToken session's caller and principal ARN are its user's, and a federated session's are its federated-user ARN, with account:name as its user ID, as GetCallerIdentity reports for a federated user. The unit test that pinned the GetSessionToken bypass now checks that a session stored without an issuer is no credential; unit tests cover each kind of issuer, the deny-only context of a federated session without a policy, and that the issuer survives persistence. Integration tests (IAM and S3 enforcement, real SigV4) cover the role-name federation, the intersection, the no-policy session, the GetSessionToken session and its AssumeRole, a bucket-policy Deny keyed on the user's aws:PrincipalArn, both kinds of session staying within the user's permissions boundary, a session of a recreated user under a bucket policy granting everyone, and a bucket policy naming a federated user against its user's explicit Deny, and a federated session refused IAM and AssumeRole although both its user and session policy allow them; the SCP integration test now also checks a root-minted session. All of them fail on main. Tests that built an STS session credential as a role-less session with no issuer, a shape Floci no longer creates, now build one the account root minted, or a presigned-URL session, as production does. |
||
|
|
436c15ca38 |
fix(sts): reject AssumeRole for roles that do not exist (#4463)
* fix(sts): từ chối AssumeRole khi role không tồn tại trong IAM AssumeRole trước đây cấp credential cho mọi role ARN, kể cả role chưa từng được tạo (iam:GetRole trả NoSuchEntity). Giờ trả AccessDenied như AWS, bất kể enforcement có bật hay không; trust policy vẫn chỉ được đánh giá khi enforcement bật. Các test cũ assume role chưa tạo được sửa để tạo role trước. Closes #4392 * fix(sts): so sánh chính xác role ARN và cập nhật compatibility tests - StsQueryHandler: kiểm tra roleArn khớp chính xác role.getArn() để tránh chấp nhận role cùng tên khác path - StsQueryHandlerTest: đổi tham số helper sang IamRole thay vì Optional, bổ sung test case từ chối role khác path - AssumeRoleTrustPolicyIntegrationTest: sửa Javadoc mô tả đúng hành vi từ chối unknown role - Cập nhật compatibility tests (Java, Node, Python, AWS CLI) để tạo role trước khi assume và kiểm tra lỗi 403 khi role không tồn tại * fix(sts): accept partition-correct role ARNs and strictly catch cleanup exceptions - StsQueryHandler: match role ARN structurally using AwsArnUtils to admit valid noncommercial partition ARNs - StsQueryHandler: preserve caller partition when generating assumedRoleArn - StsTest, test_sts.py, sts.test.ts: only ignore NoSuchEntity/EntityAlreadyExists in cleanup, re-raising unexpected errors per AGENTS.md - StsQueryHandlerTest, AssumeRoleTrustPolicyIntegrationTest: add unit and integration coverage for partition-correct role ARNs * fix(sts): preserve role partition in resolved session caller ARN * fix(sts): preserve stored role partition in assumed identity * fix(sts): validate web identity role ARN * fix(sts): require role existence in AssumeRoleWithWebIdentity and reuse path helpers * fix(sts): keep IAM ARN partition behavior unchanged * fix(sts): derive trust caller account from identity ARN * fix(iam): migrate legacy credential reports by partition * fix(iam): serialize legacy credential report migration * test(iam): make credential report race deterministic * fix(sts): address review feedback * fix(sts): reuse IAM role path normalization |
||
|
|
4e2c1d11ff |
fix(sts): evaluate AssumeRole trust-policy conditions against the real caller (#4716)
With IAM enforcement on, AssumeRole matched a trust policy on its Action and Principal only. The Condition block was never read and the ExternalId request parameter was ignored, so a role guarded by sts:ExternalId, the documented confused-deputy guard, could be assumed without it, and a conditional Deny applied whether or not its condition held. Trust-policy conditions now go through IamPolicyEvaluator's condition engine, through a new package-private conditionMatches, so they get the same operators as identity and resource policies. The request context holds sts:RoleSessionName, sts:ExternalId when the caller sends one, the global keys the enforcement filter already provides, and aws:PrincipalArn. A role session is now matched as the role that issued it, through that role's own ARN, path included. AssumeRole records it on the session when it issues one, and a new IamService.resolvePrincipalArn reads it back as is, so an old session keeps naming its role even after a same-named role replaces it. The evaluator used to rebuild the role ARN from the assumed-role session ARN, which names the role without its path, so a session of role/team/App was compared as role/App: a Principal naming the role refused it, and a condition on aws:PrincipalArn saw the wrong value. IAM stores a Principal naming a role as the role's unique ID, and aws:PrincipalArn is the ARN of the role that was assumed, so both are the full role ARN. A negated operator on an absent key now holds, as the IAM User Guide says for every condition operator but the IfExists forms and Null: "If the policy condition requires that the key is not matched, such as StringNotLike or ArnNotLike, and the right key is not present, the condition is true." evaluateConditionBlock failed every operator on an absent key, so once trust conditions were evaluated a Deny with StringNotEquals on sts:ExternalId stopped refusing a call that omits ExternalId. The change is in the shared engine, so identity, resource and SCP conditions get the same rule; the set operators keep their own rule for an absent key. The AppSync service-trust path from #4555 had its own small condition evaluator for aws:SourceArn and aws:SourceAccount. It now uses the same engine with those two keys as its context, which also makes negated operators such as StringNotEquals work there instead of refusing the document. A Condition that is not an object of non-empty operator objects still invalidates the whole trust document, now on every path. The trust check also resolved the caller's account from the Authorization header alone, where only a 12-digit key names an account. An IAM user's or a role session's key, and any presigned request, therefore counted as the default account and could assume a role that trusts only that account. The check now uses the account the request was resolved to, and reads a presigned caller's key from X-Amz-Credential. |
||
|
|
cd9843f5bd |
fix(sts): preserve assumed role session identity (#4403)
* fix(sts): preserve assumed role session identity * test(sts): cover federated caller identity round trips |
||
|
|
90fa707145 |
fix(sts): return ExpiredTokenException for an expired web identity token (#3210)
* fix(sts): return ExpiredTokenException for an expired web identity token AssumeRoleWithWebIdentity mapped every WebIdentityTokenVerifier failure to InvalidIdentityToken, so an expired but otherwise valid IRSA token got the same wire error as a bad signature or wrong issuer. Real STS reports the expiry case as ExpiredTokenException so callers can refresh and retry. Fixes #3205 * test(eks): inject EksOidcService through the test constructor |
||
|
|
1de6b80035 |
fix(sts): reject unverified web identity tokens (#3151)
* fix(sts): reject unverified web identity tokens * test(sts): expect invalid web identity tokens to fail * fix(sts): make unknown issuer rejection opt in |
||
|
|
7e5afae61b |
feat(eks): support IRSA with a real OIDC issuer and JWT validation (#2108)
* feat(eks): support IRSA with a real OIDC issuer and JWT validation
Every EKS cluster now gets an OIDC identity provider, so the full IRSA flow
works end to end without mocked or hardcoded tokens.
CreateCluster generates an RSA-2048 keypair and an AWS-shaped issuer URL,
returned by DescribeCluster as identity.oidc.issuer. The issuer is a faithful
string for building trust policies but is never dereferenced: STS resolves the
signing key in-process via a new OidcIssuerKeyLookup port, declared in
core.common so services.iam does not depend on services.eks.
Key material lives in storage separate from the Cluster model. Cluster is
serialized straight onto the DescribeCluster wire response, so a private key
carried there would leak; @JsonIgnore would instead lose it across restarts and
break tokens minted earlier.
sts:AssumeRoleWithWebIdentity previously accepted any non-blank token and
returned a hardcoded subject. It now verifies, but only for issuers Floci hosts:
- RS256 signature against the cluster's public key
- iss matches the issuer exactly
- aud contains sts.amazonaws.com
- exp / nbf, with 60s of clock-skew tolerance
- the role's trust policy, via a new WebIdentityTrustPolicyEvaluator matching
Principal.Federated and the Condition block
The response now carries the token's real claims in
SubjectFromWebIdentityToken, Provider, and Audience. Bad tokens return
InvalidIdentityToken (400); a trust policy that does not permit the subject
returns AccessDenied (403) — a check the web-identity path was missing entirely.
Tokens from an issuer Floci does not host stay permissive, since Floci cannot
verify a third-party signature. Existing behaviour is therefore unchanged and no
configuration flag is required.
WebIdentityTrustPolicyEvaluator is a sibling of AssumeRolePolicyEvaluator rather
than an extension of it: that evaluator serves sts:AssumeRole, hardcodes that
action, reads only Principal.AWS, and ignores conditions. Condition values are
compared with exact, case-sensitive equality instead of the existing
globMatches, which lowercases both operands — case-folding an OIDC subject would
silently admit a different service account.
Because Floci has no kubelet to project a token into a pod, a local-dev harness
can mint one via POST _floci/eks/clusters/{name}/oidc-token and write it to the
file named by AWS_WEB_IDENTITY_TOKEN_FILE. Signing stays server-side so the
private key never leaves Floci. OIDC discovery and JWKS routes are served under
the same _floci namespace, for fidelity rather than because anything fetches
them; the AWS-shaped issuer path is not resolvable by Floci's embedded DNS and
would collide with S3's path-style catch-all.
Adds 51 tests: unit coverage for the verifier, the trust-policy evaluator, and
the OIDC service, plus an end-to-end integration test covering the mint ->
assume -> credentials path and its negative cases (wrong service account,
tampered signature, wrong audience, expired, alg:none).
* fix(iam): close two web-identity validation gaps and backfill cluster OIDC state
Three defects found in review of the IRSA change.
An unsigned "header.payload." token bypassed validation entirely. verify()
split with a -1 limit so a trailing empty segment was preserved, but
parseClaims() — which backs peekIssuer() — did not. Java drops trailing empty
strings by default, so such a token split into two parts, its issuer went unseen,
and STS classified it as an opaque third-party token: signature, claim, and
trust-policy checks were all skipped and credentials were issued for a JWT that
was never signed. Both split sites now pass -1.
StringLike and StringNotLike on an OIDC condition key folded case. They
delegated to IamPolicyEvaluator.globMatches, which lowercases both operands, so
a trust policy scoped to one service account or namespace would admit another
differing only in case — the exact hazard the StringEquals branch was written to
avoid. Adds a case-sensitive glob and uses it for both operators. Action matching
still uses globMatches, which is correctly case-insensitive.
Clusters persisted before this feature never gained an issuer or key, so after an
upgrade DescribeCluster reported no identity.oidc.issuer, minting returned 400,
and the JWKS routes 404'd until the cluster was recreated. EksService now
backfills on startup, and re-runs ensureKey for clusters that already have an
issuer so a restart cannot leave a known issuer without its signing key.
Each fix has a regression test confirmed to fail without it.
* fix(eks): keep IRSA OIDC state scoped to the cluster's owning account
The startup backfill read clusters across every account via scanAllAccounts() but
wrote them back with the request-scoped put(), which resolves to the default
account outside a request context. A cluster owned by any other account kept its
issuer-less record while a duplicate appeared under the default account, leaving
DescribeCluster and the IRSA endpoints broken for the owner. The backfill now
takes the account from the cluster record and writes with putForAccount, per the
pattern StorageFactory documents for work running outside a request.
The same root cause affected key lookup more seriously. findVerificationKey used
the account-scoped scan(), so an issuer owned by a non-default account went
unresolved — and an unresolved issuer is treated as a third-party provider, so
STS accepted the token with no signature, claim, or trust-policy check at all.
It now scans every account, which is correct regardless: an issuer URL is
globally unique, and the account calling AssumeRoleWithWebIdentity need not be
the one that owns the cluster.
deleteKey and findKeyByCluster stay account-scoped; both are only reached from
request-scoped paths (DeleteCluster and the JWKS route), where the caller's
account is the right scope.
Both fixes have a regression test confirmed to fail without them.
|
||
|
|
d54a307ca9 |
feat(iam): enforce AssumeRole trust policies when enforcement is enabled (#1552)
* feat(iam): enforce AssumeRole trust policies when enforcement is enabled When floci.iam.enforcement-enabled is true, STS AssumeRole now evaluates the target role's trust policy (AssumeRolePolicyDocument) against the caller and returns AccessDenied if it is not permitted. Enforcement is off by default, so existing behavior is unchanged. Trust policies are principal-centric and carry no Resource element, so the identity/resource-oriented IamPolicyEvaluator cannot evaluate them. A focused AssumeRolePolicyEvaluator matches each statement's Action (sts:AssumeRole) and AWS Principal (account id, account-root ARN, exact principal ARN, or "*") against the caller, with explicit Deny taking precedence. The role is resolved in its own account (from the role ARN) via a new IamService.findRole overload, since roles are account-namespaced. Roles unknown to Floci stay permissive to preserve backward compatibility. Tests: unit coverage for the evaluator across principal/action/deny/malformed cases, plus an enforcement-enabled integration test asserting a permitted caller succeeds, an unauthorized caller is denied, and an unknown role stays permissive. * docs(sts): restore Configuration section and note NotAction limitation Greptile review on #1552: - Restore the FLOCI_SERVICES_STS_ENABLED Configuration section that was dropped when the Trust Policy Enforcement section was added. - Document that NotAction is not evaluated (a Deny with NotAction won't block). * fix(iam): honor NotAction in AssumeRole trust statements evaluateStatement only inspected the Action key, so a trust statement using NotAction returned NO_MATCH and was skipped entirely. A Deny that should block sts:AssumeRole (NotAction excluding some other action) was therefore ignored, over-permitting AssumeRole when IAM enforcement is enabled. Add actionApplies() mirroring IamPolicyEvaluator's Action/NotAction semantics: Action applies when any pattern matches, NotAction applies when none match. Covered by three new AssumeRolePolicyEvaluatorTest cases. * fix(iam): match an assumed-role caller against a role-ARN trust principal When a caller uses assumed-role temporary credentials, resolveCallerArn (rightly, for GetCallerIdentity) yields the STS assumed-role ARN (arn:aws:sts::ACCT:assumed-role/Role/session). enforceTrustPolicy passes that to the trust-policy evaluator, but role trust policies name the role's IAM principal ARN (arn:aws:iam::ACCT:role/Role) — the canonical form AWS resolves the session back to. So a legitimate role-to-role AssumeRole was denied. matchesAwsPrincipal now also normalizes an assumed-role caller ARN to its underlying IAM role ARN and matches the principal against that, while still matching an exact session-ARN principal. resolveCallerArn is unchanged, so GetCallerIdentity keeps returning the assumed-role ARN. Adds AssumeRolePolicyEvaluatorTest cases for role-ARN match, differing-role denial, and exact session-ARN match. |
||
|
|
42669aaed9 | fix(config): make runtime defaults explicit (#1389) | ||
|
|
9e35046647 |
Docs/enviroment instead yml (#764)
* docs: moving all config to env instead of yml * docs: sync with main and new features * docs: reverting docker-compose.yml |
||
|
|
a32b7f1f3b |
docs: comprehensive audit sweep + CHANGELOG backfill (1.1.0-1.5.2) (#326)
CHANGELOG.md was empty for the 1.1.0-1.5.2 release cycle and service docs had drifted from code behaviour. This sweep reconciles docs against the current codebase on upstream/main. - Backfill CHANGELOG.md for 1.1.0 through 1.5.2 from git history - Correct exact operation counts in docs/services/index.md: S3 (~30 -> 58), Lambda (~25 -> 30), API Gateway v1 (~24 -> 62). Counts now come from the actual dispatch handlers rather than @Path annotation counts. - Rewrite README "Supported Services" table to drop per-service op counts (they drift too fast); point readers at docs/services/index.md - Update 24 service docs for accuracy, add "Not Implemented" sections where relevant (s3.md, lambda.md, api-gateway.md) - Refresh configuration and getting-started docs - Add EventBridge Scheduler and AppConfig to mkdocs nav - Add AppConfig / AppConfigData rows to README and services index following the 1.5.2 upstream release |
||
|
|
61433f59ab | firt commit |