mirror of
https://github.com/floci-io/floci.git
synced 2026-12-06 03:28:18 -05:00
AWS requires the caller of RotateSecret to hold lambda:InvokeFunction on the rotation function as well as secretsmanager:RotateSecret (Secrets Manager API Reference, RotateSecret, "Required permissions"). Floci checked only RotateSecret and then invoked the function in-process, so under IAM enforcement a caller refused lambda:InvokeFunction could still run any function it could name by configuring it as a rotation function. RotateSecret now authorizes the invoke for the same caller the filter evaluated, against the exact function the rotation will run (the requested ARN, or the one already configured, with a bare name or partial ARN resolved in the secret's account and Region), and the rotation then invokes that same full ARN. Invoking the reference as given would let a name or partial ARN resolve in whatever account the rotation thread sees, so the function checked and the function run could differ. The check runs before the function is looked up or the secret changed, so a refused call leaves nothing configured for the scheduled sweep to invoke later. A refusal is reported as Secrets Manager reports one: AccessDeniedException with HTTP 400 (API Reference, "Common Errors"). A rotation function that does not exist is now reported the way AWS reports it too: AccessDeniedException, HTTP 400, "Secrets Manager cannot invoke the specified Lambda function. Ensure that the function policy grants access to the principal secretsmanager.amazonaws.com.", with the secret's rotation settings left as they were. It used to be ResourceNotFoundException with HTTP 404. The caller credential reaches the handler through IamEnforcementFilter.requestAuthorization, the filter's own header-or-presigned logic, so a presigned request is checked the same way. Requests with no caller credential, such as API Gateway service integrations, and rotations started by the scheduled sweep are unchanged. With IAM enforcement off the caller check does not run; the missing-function response above applies either way.