mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 15:21:05 -05:00
UpdateAccessKey refused the Expired that statusType permits, answered a message of its own making, and read the status only after it had looked the key up, so a bad key carrying a bad status answered NoSuchEntity 404 where the shape is what AWS answers for. The reference's Valid Values line on the operation reads "Active | Inactive | Expired" and the pinned model's statusType holds those same three. The fix is one call rather than a new rule. requireStatusFromEnum already serves UpdateSigningCertificate, UpdateSSHPublicKey and UpdateServiceSpecificCredential: it validates before each of those lookups and answers the rendering a recording of the third shows, naming neither the offending value nor the permitted set. UpdateAccessKey was the one operation of the four not calling it, so it calls it, and the helper's javadoc and the set behind it say four instead of three. UserName was the other half. The page carries the sentence DeleteAccessKey carries, "if the UserName is not specified, the user name is determined implicitly based on the AWS access key ID used to sign the request", and the handler passed the raw parameter straight through, so a call that omitted it compared the key's owner against null and answered NoSuchEntity. It resolves through resolveUserName now, as GetUser, ListAccessKeys and DeleteAccessKey do, and AccessKeyId is read through requireParam, as the sibling handlers read the ids they require. AWS::IAM::AccessKey refused Expired as well, and its own Allowed values line in the CloudFormation template reference reads "Active | Inactive | Expired". Leaving it would have been the same drift on a second surface, and taking Expired on the API while refusing it in a template is worse than either alone. The provisioner keeps its own guard, which runs before a key is created so that a refusal cannot orphan one, and its own message, which names the resource it refuses. One more drift came out of reading the method back, and it is the one that mattered. updateAccessKey is a read-modify-write that took no lock, where each of the three sibling status operations holds its family's. There was no access key lock at all: createAccessKey counted a user's keys and only then stored another, and the user rename rewrote each key's owner outside one, the single credential family that rename did not guard. Measured before the fix, racing the calls against each other: an update racing a delete wrote the deleted key back on 80 of 2000 trials, and four callers racing the two-key quota left more than two on 226 of 500. One accessKeyLock now covers the count and the store, the lookup and the delete, the read-modify-write, and the rename's loop, and the owner check that the delete and the update each carried is one helper. Substituting a fresh monitor for that lock at all four sites fails the quota case on its first trial and the resurrection case by its eighty-third. Three more places the lock has to reach, each measured the same way. The rename read the key list before taking the lock and rewrote it inside, so a delete that landed in between was undone and the key came back under the new name, where it authenticates again; the read moves inside the lock, where every other credential family already reads its own, and putting it back outside fails by the third trial. createAccessKey confirmed the user before taking the lock and deleteUser checked for keys without holding it, so a create could store a key for a user the delete had just removed; the confirmation moves inside the lock, the way UploadSigningCertificate's already is, and deleteUser holds the lock across its key check and the delete, outermost of the five it nests, which is the order UpdateUser leaves intact by taking that lock on its own. Reverting either half alone puts the orphan back, by the seventeenth trial and by the second. Fifteen tests. Seven over the wire: Expired stored and read back, a status outside the set, an absent status, an absent key id, the order against a key that is not there, a call that names no user, and another user's key still answering NoSuchEntity. Three on the service for the three statuses, the order, and the absent status. One on the provisioner for a template declaring Expired. And four in IamConcurrencyTest, which raced six collections and no credential family before this: an update against a delete, four creates against the quota, a rename against a delete, and a create against DeleteUser. The two refusals also read the key back, over the wire and on the service, so a validation that wrote before it refused would not pass them. What is left is the count: AWS reports "2 validation errors detected" when the id and the status are both wrong, where every message here leads with one, which is the follow-up #5280 already carries.