I can able to generate preSignedUrl and add Expration (For uploading an Image) successfully but how can I secure the url from a malicious person.
like for example in my nodejs server i have users who can post images, and some hacker logs in to my website get his jwt token, gets his s3 preSignedUrl and abuse my s3 storage.
how do I increase security ?
You can visit my website to get a presignedUrl to post a file visit : http://khelkhelo.in
// This is how I reproduce how a hacker can abuse the service
const { default: axios } = require("axios");
async function uploadFromMaliciousSource() {
// hacker will create account in my website and get his own jwt token
// signedurl we are using here is to upload images in a user post
const { data: signedUrl } = await axios.get("http://khelkhelo.in", {
headers: {
"x-auth-token": "jwt token of a user",
},
});
// here hacker can have access to preSignedurl and can upload his OWN CONTENT like sharing movies
const formdata = new FormData()
formdata.append() // ...
}
uploadFromMaliciousSource();