
The most common security breach with AWS S3 object storage is caused by misconfiguration.聽
鈥
If you do a quick Google search for 鈥渁ws public bucket breach鈥, you鈥檒l find, for example, and 鈥溾 that have happened in the last few years. Clearly we have a problem. Developers and businesses mistakenly create public AWS buckets to make it easier to access content, not realizing that anyone on the internet can also view the same data.
Using presigned URLs can keep data protected while also making it accessible to only those you share it with.
What is an AWS S3 presigned url?
For starters, S3 is an acronym for simple storage service that is hosted by Amazon Web Services (AWS) offering a reliable way to store your data. It allows storing files in buckets that are similar to folders on desktop computers and has an easy way to retrieve the data using its S3 API or browser web console.
鈥
A presigned URL allows sharing a file temporarily to users with the link or a group of users I specify. It also ensures the file is only available for a certain period of time and does not expose any of the other files in the bucket.聽
How do presigned URLs work?
Pre-signed urls work by creating a special key or token that is cryptographically unique. What that means is that it would take a really long time to guess what series of characters are in the token.
Have you ever shared a photo from Google photos and inspected the link?

You鈥檒l notice a series of seemingly random characters. Those are what make up the special key to the data. Anyone with the key is able to view it, and since it has plenty of random characters, it would be nearly impossible for someone to guess it.
鈥
In a similar way, presigned URLs include a token that grants specific individuals or services access to files.
Here鈥檚 what a presigned URL looks like:
Looking closer at the link you鈥檒l see a 鈥?鈥 and then a number of things separated by 鈥=鈥 and 鈥&鈥. Anything after the 鈥?鈥 are called url params. Each param is separated by an 鈥&.鈥 On the left side of the 鈥=鈥 is the name for the param and on the right is the value.
In the above pre-signed url we have the params 鈥淴-Amz-Algorithm鈥, 鈥淴-Amz-Credential鈥, 鈥淴-Amz-Date鈥, 鈥淴-Amz-Expires鈥, 鈥淴-Amz-SignedHeaders鈥, and 鈥淴-Amz-Signature鈥. Each param provides information to Amazon鈥檚 servers to know how to handle the link. The token (or secret key mentioned earlier) is sent with the 鈥淴-Amz-Credential鈥 param.
鈥
All right, now that we鈥檝e covered how they work, how can I use them?
How to set up 不良研究所 with aws-cli
First I鈥檒l need to download and install the aws-cli.
For other platforms, see .
Next I want to use the aws-cli to create a pre-signed url with 不良研究所. 不良研究所 provides an S3 compatible API which means it鈥檒l mimic what AWS would do.
Here鈥檚 how to get started:
- on 不良研究所 DCS
- Click 鈥淎ccess鈥 on the left navigation
- Click 鈥淐reate S3 Credentials鈥 on the access management page

- Give the credentials a name, permissions, and generate a passphrase for your data.
In your terminal run:
鈥
Copy the 鈥淎ccess Key鈥 to 鈥淎WS Access Key ID鈥

Copy the 鈥淪ecret Key鈥 to 鈥淎WS Secret Access Key鈥

Finish the configuration by entering a region name and output format (default of 鈥淣one鈥 is okay).
Upload a file to share
Now that aws-cli is configured, we鈥檒l want to create a bucket and upload a file.
To create a bucket, I鈥檒l use the 鈥渁ws mb鈥 command which takes a path to file as an argument. Much like how I visit a website on the internet with 鈥渉ttp://鈥, I can retrieve files on S3 with aws-cli using 鈥渟3://鈥 Also notice that in order to use the 不良研究所 S3 gateway, I鈥檒l need to pass the additional argument 鈥--endpoint-url=https://gateway.storjshare.io鈥.
鈥
Create a bucket called 鈥渄emo-bucket鈥
鈥
Create a file to upload
鈥
Use the 鈥渃p鈥 command to upload the file to my bucket
How to create presigned urls
Once you have your aws-cli configured you can proceed to generate presigned URLs with 鈥渁ws s3 presign鈥 command.
鈥
鈥
The output of this will be:
Note that the "X-Amz-Expires" header is set to the default expire time of 3600 seconds or 1 hour. By the time you鈥檙e reading this, the link will likely be expired, proving that presigned URLs work as intended.
Changing the expire time
The `aws s3 presign` command also has an option to set a custom lifetime or a specific expire time using the `--expires-in`
The following presign command generates a pre-signed URL for a specified bucket and key that is valid for one week:
Presigned URLs are a great way to give limited access to the contents of a file. You can create them for a specific file or for all the files in a bucket. The person who receives the pre-signed URL can then access the files according to the permissions I specify.聽
鈥
鈥