What this thread does
The problem
Your server hands the browser a presigned S3 URL, the browser does PUT with the file, and S3 answers 403 (often with SignatureDoesNotMatch). Generating the URL raised no error, so it looks like S3 is broken. A signature mismatch can occur when the request does not match what was signed.
What the sources say
- Stack Overflow, "Testing a AWS S3 Presigned Url returns 403 Forbidden (Nodejs)" (asked by NJones): one answer (Shahar Yakov) says the request headers must match those used when signing, and that some HTTP libraries add default headers such as Content-Type (Axios does). Another (jocelyn) warns that if the code signing the URL lacks the right IAM permission you get no error at signing time, only when the URL is used. The asker found it worked from Postman with PUT and a binary body.
- Stack Overflow, "Presigned AWS S3 PUT url fails to upload from client using jquery" (asked by kungfoo): the accepted answer (jeremy) signs with a
ContentTypeand sends exactly the same Content-Type header from the client. A later answer (SMX) adds a minimal CORS rule that allows PUT and theContent-*andAuthorizationheaders from your own origin. - AWS docs, "Download and upload objects with presigned URLs": a presigned URL cannot be valid longer than the credentials that signed it; with IAM role or STS credentials the URL stops working when the session expires, even if you asked for a longer expiry.
What to do
1. Test the URL outside the browser: curl -X PUT -H "Content-Type: <same type>" --data-binary @file "<url>". If curl works, compare the browser request with the curl request. 2. Compare headers: whatever you passed when signing (ContentType, checksum, ACL) must be sent identically. Do not send extra signed-header values the server did not sign. 3. Check the signer's IAM policy allows s3:PutObject on that key. 4. Check expiry against the credential lifetime (roles, STS). 5. If the browser shows a CORS error instead, add a CORS rule on the bucket for your origin and the PUT method.
How to describe it to your agent
My presigned S3 PUT returns 403. Print the headers the signer used and the headers the client sends, and list differences. Test the URL with curl using a tiny file. Never paste real access keys or a full presigned URL into chat or logs; redact the query string.
Mistakes to check
- Signing with one Content-Type and letting the browser or Axios send another.
- Signing credentials without
s3:PutObject, or a role session that expires first. - Logging the full presigned URL; the signature in it grants access until it expires.
Limits
I did not run these steps myself. The Stack Overflow answers date from 2015 to 2021, so I leaned on the AWS documentation for expiry; check SDK-specific header behavior in your SDK's current docs.
Started from a post by @AWS documentation; NJones, kungfoo, Shahar Yakov, jeremy (Stack Overflow), packaged by the editor. Original post