S3 Is A Security Nightmare (Common Exploit Showcase)

Theo - t3․gg
17 Jun 202416:47

Summary

TLDRThe video script discusses common security flaws in Amazon S3 configurations, highlighting how pre-signed URLs can be misused for cross-site scripting attacks. It showcases real-world examples of vulnerabilities discovered by community member Eva, emphasizing the importance of proper authentication and file handling. The script also promotes 'UploadThing', a tool designed to simplify secure file uploads, and advises on best practices to avoid such security issues.

Takeaways

  • 🔒 S3 (Amazon Simple Storage Service) security issues are common due to misconfigurations that can lead to serious vulnerabilities.
  • 👀 A blog post highlighted by the speaker emphasizes the widespread problem of S3 mismanagement and the potential for exploitation.
  • 📈 The speaker mentions a previous video about a massive data breach involving Firebase, which underscores the severity of such security issues.
  • 🛑 Pre-signed URLs in S3 can be abused if not properly secured, leading to cross-site scripting (XSS) and unauthorized file uploads.
  • 🔑 Authentication checks are crucial at every step of the file upload process to prevent unauthorized access and uploads.
  • 📦 The process of uploading files directly to S3 can bypass the server, which can reduce costs and improve latency but also introduces risks.
  • 🚫 Allowing users to control the file path or key in S3 uploads can lead to overwriting other users' files and should be avoided.
  • 🤖 Automated tools and services like UploadThing are designed to simplify secure file uploads and reduce the risk of misconfiguration.
  • 🛠️ The importance of setting proper authentication and authorization for cookies and ensuring that file upload endpoints are secure against XSS.
  • 💡 The script discusses specific examples of vulnerabilities found in services like Tally and P, where improper S3 configurations were exploited.
  • 🔄 The video script serves as a cautionary tale, urging developers and companies to properly secure their S3 implementations to prevent data breaches and service abuse.

Q & A

  • What is the primary focus of the video script about S3?

    -The video script focuses on the security issues with Amazon S3, discussing common configuration mistakes that can lead to security flaws, and the potential consequences of not setting up S3 correctly.

  • Why did the speaker decide to make a video about S3 security issues?

    -The speaker decided to make a video about S3 security issues after finding a blog post that immediately caught their attention and added to their to-do list for video content.

  • What is the significance of the pre-signed post URL in S3 uploads?

    -A pre-signed post URL is significant because it allows a user to upload a file directly to S3 within a specific time frame and with specific permissions, bypassing the need to send the file through a server, which can reduce costs and improve latency.

  • What are the potential security risks of allowing users to upload files directly to S3 without proper checks?

    -The potential security risks include cross-site scripting (XSS) attacks, where malicious HTML or JavaScript files can be uploaded, and the possibility of overriding other users' files if the server does not check for file existence.

  • How can a poorly configured S3 bucket lead to account takeovers?

    -A poorly configured S3 bucket can lead to account takeovers if HTML files are uploaded to a domain where cookies are not properly set, allowing an attacker to access and exploit the cookies for unauthorized access.

  • What is the role of authentication in the process of uploading files to S3?

    -Authentication is crucial to ensure that the user uploading a file is the right user and has the necessary permissions to perform the upload, preventing unauthorized access and potential security breaches.

  • Why is it important to manage file uploads on your own server instead of allowing direct uploads to S3?

    -Managing file uploads on your own server allows you to perform authentication checks and ensure that the files being uploaded are legitimate and do not pose a security risk, which is not possible with direct uploads to S3.

  • What is the purpose of using a service like UploadThing for S3 uploads?

    -UploadThing is designed to simplify the process of securely uploading files to S3, enforcing authentication and proper file handling, making it difficult to set up incorrectly and reducing the risk of security vulnerabilities.

  • What are some best practices to avoid when securing S3 uploads?

    -Best practices to avoid include allowing users to control the file path and key, not setting cookies properly, and not authenticating users on your own server before allowing file uploads.

  • How can third-party libraries contribute to S3 security issues?

    -Third-party libraries can contribute to S3 security issues if they are not configured correctly or if they lack proper documentation, leading to common pitfalls and misconfigurations that can be exploited.

  • What alternatives are available for simplifying S3 uploads and management?

    -Alternatives for simplifying S3 uploads and management include services like Backblaze B2, Filestack, and UploadThing, which offer APIs and tools to securely and efficiently manage file uploads to S3.

Outlines

00:00

🔒 Insecure S3 Configurations and Their Risks

The video discusses the common security issues with Amazon S3 configurations, highlighting how misconfigurations can lead to significant security flaws. It mentions a blog post that the speaker found enlightening and plans to cover in a video, focusing on the improper setup of S3 and the ease with which accounts can be compromised. The speaker references Eva's work in exposing vulnerabilities in S3 implementations, including a past exploit involving Firebase that compromised numerous websites and potentially exposed billions in bank credentials. The explanation includes a technical diagram to illustrate the process of file uploads to S3, the importance of authentication, and the potential for abuse through pre-signed URLs if not set up correctly.

05:00

🕵️‍♀️ Cross-Site Scripting (XSS) Vulnerabilities in S3 Uploads

This paragraph delves into the specific vulnerabilities found in S3 uploads, particularly with pre-signed posts, as discovered by Eva. It explains how poor handling of content types can allow for the uploading of HTML files, which, if not properly secured, can lead to cross-site scripting attacks. The explanation covers how cookies set on a domain can be accessed by scripts running from that domain, leading to account takeovers if exploited. The video uses the example of a website called Tally, which allows form creation with images and had a vulnerability where HTML files could be uploaded and served, potentially leading to XSS attacks. The discussion includes the technical process of how an SVG file, treated as XML, could be used to execute JavaScript in an HTTP-only environment, bypassing certain security measures.

10:01

🛑 Overriding Files and Insecure S3 Upload Paths

The speaker addresses another common vulnerability where services allow users to control the file path and key during S3 uploads, which can lead to file overriding if not properly checked by the server. Using the example of a service called P, the video explains how a user was able to change the key in a pre-signed URL to override another user's file upload. The issue is highlighted as a widespread problem with many services, and the video suggests that using services like UploadThing can help mitigate such risks by managing file uploads more securely. The speaker emphasizes the importance of proper authentication and avoiding client-side control over file keys to prevent such vulnerabilities.

15:01

🛠️ Solutions for Secure S3 File Management

In the final paragraph, the speaker wraps up by emphasizing the complexity and common pitfalls of managing S3 uploads, especially when using third-party libraries that may not be configured correctly. The video suggests that it can be challenging to set up S3 securely, but it is essential to do so to avoid the risks discussed. The speaker promotes their own product, UploadThing, as a solution that simplifies secure file uploads by enforcing correct configurations by design. They also mention other services that can help manage S3 uploads securely, such as Filestack and Simple File Uploader, and encourage viewers to check out Eva's work for further insights into security best practices.

Mindmap

Keywords

💡S3

S3, or Amazon Simple Storage Service, is a scalable object storage service provided by Amazon Web Services (AWS). It is central to the video's theme as it discusses the security issues related to S3 configuration. The script mentions how misconfigurations can lead to serious security flaws, and it uses S3 as an example of where and how these issues can occur.

💡Security Flaws

Security flaws refer to weaknesses or vulnerabilities in a system that can be exploited by attackers. In the context of the video, security flaws are associated with improper configurations of S3, which can lead to data breaches or unauthorized access. The script highlights the importance of securing S3 to prevent such flaws.

💡Pre-Signed Post URL

A pre-signed post URL is a time-limited URL generated by a server that allows direct uploads to S3 without going through the user's server. This concept is crucial in the video as it explains how skipping the server for file uploads can reduce costs but also introduces security risks if not handled correctly.

💡Cross-Site Scripting (XSS)

Cross-Site Scripting, often abbreviated as XSS, is a type of security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. The video discusses how poor handling of content types in S3 uploads can lead to XSS attacks, emphasizing the severity of such flaws in web security.

💡Authentication

Authentication in the video refers to the process of verifying the identity of a user or device. It is a critical aspect of securing S3 uploads, ensuring that only authorized entities can upload files. The script points out the necessity of authentication checks at every step of the file upload process.

💡Egress Costs

Egress costs are the fees charged for data transferred out of a cloud service, such as AWS S3. The video script discusses how direct uploads to S3 can help reduce egress costs by eliminating the need to transfer data through an intermediary server.

💡Ingress

Ingress, in the context of cloud services, refers to incoming network traffic to a server or service. The script mentions that direct uploads to S3 can also reduce ingress costs, as the data does not first enter the user's server before being sent to S3.

💡File Upload Vulnerabilities

File upload vulnerabilities are security weaknesses that can occur when a system allows users to upload files without proper validation or restrictions. The video script provides examples of how allowing users to control the file path or key in S3 uploads can lead to file override vulnerabilities.

💡Eva

Eva is a community member mentioned in the script who has discovered numerous security issues with S3 and other implementations. The video references Eva's work to highlight the prevalence and severity of S3 security flaws, emphasizing the importance of proper security practices.

💡UploadThing

UploadThing is a service mentioned in the video that aims to simplify and secure file uploads to S3. The script discusses how UploadThing addresses common security pitfalls by enforcing proper authentication and file handling, positioning it as a solution to the issues discussed in the video.

Highlights

Security issues with Amazon S3 configurations can lead to massive flaws, and common mistakes are discussed.

The importance of correctly setting up S3 to prevent potential exploits is emphasized.

Pre-signed POST URLs can be abused for cross-site scripting or unwanted file uploads if not properly secured.

Diagrams are used to explain the process of file uploads and permissions in S3.

Authentication checks are crucial at every step of the file upload process to the server.

The cost and bandwidth implications of file uploads through a service to S3 are discussed.

Pre-signed POST URLs are a way to upload files directly to S3, bypassing the need for server ingestion.

The potential for mistakes with pre-signed POST URLs is highlighted, especially with custom file delimiters.

Cross-site scripting (XSS) vulnerabilities due to poor handling of content types in S3 uploads are explained.

The impact of cookies' scope on domain and subdomains in the context of S3 security is discussed.

Eva's discovery of S3 vulnerabilities in companies and the widespread issue of incorrect S3 setups.

The exploitation of S3 through SVG XML uploads and the risks of HTTP-only cookies.

The use of UploadThing as a solution to common S3 upload problems, emphasizing its ease of setup and security.

The importance of not allowing users to control the file path or key in S3 uploads to prevent overrides.

The risks associated with allowing users to set ACLs in S3 and the potential for unauthorized access.

Recommendations for securing S3, including proper cookie settings and restricting user control over file keys.

The difficulty of correctly configuring S3 due to common pitfalls and the lack of clear documentation.

The introduction of third-party services and APIs designed to simplify and secure S3 file uploads.

A call to action for viewers to correctly secure their S3 setups to prevent exploits and protect their services.

Transcripts

play00:00

I wanted to do a video about the

play00:01

security issues with S3 for a while if

play00:03

you're using it yourself right now

play00:04

there's a good chance you've made some

play00:06

configuration issues that could cause

play00:07

some massive security flaws in February

play00:09

I found this blog post and I immediately

play00:11

added it to my to-do for video content

play00:13

because I want to talk about S3 and all

play00:15

the things people do wrong with it and

play00:16

how easy it is to find like an account

play00:18

ID since then though Our Community

play00:20

member Eva has done a lot of crazy

play00:22

with S3 and other people's

play00:24

implementations on top of it and

play00:26

honestly this is a much much better post

play00:28

and a much better video and I can't not

play00:30

take the opportunity to read it and

play00:31

share with you guys the hack and the

play00:32

craziness that is how badly most people

play00:35

set up and secure their S3 if you

play00:36

recognize this blog post and this

play00:38

website it might be because of my

play00:39

earlier video 900 sites 125 million

play00:42

accounts and one vulnerability they're

play00:44

the ones who did the Firebase exploit

play00:46

that compromised a ton of websites and

play00:48

found $4 billion of potential Bank

play00:51

credentials just crazy anyways

play00:53

we're talking about S3 specifically how

play00:55

most people suck at securing it and some

play00:57

of the things that can result if you

play00:58

don't set it up correctly tldr S3

play01:01

pre-sign posts or other ways of

play01:02

uploading files can easily be abused

play01:05

with cross-site scripting or unwanted

play01:06

paths for uploads yep if you're not

play01:09

familiar with a presign post URL it's an

play01:10

important concept that'll tldr for you

play01:13

maybe this is going to be more than a

play01:15

tldr excal draw my beloved let's get

play01:19

diagramming you have a server we'll call

play01:22

this your server your server is a box

play01:25

that does things one of those things is

play01:28

make sure a user is the right user so if

play01:30

you have a user we'll have the user be a

play01:31

circle let's say this user wants to

play01:33

upload there's a couple different ways

play01:35

they could do it they could literally

play01:36

just send the file straight to your

play01:38

service which is a file upload where the

play01:43

user just immediately posts the file

play01:44

maybe it's part of some form data maybe

play01:46

they're just sending it as a post there

play01:49

in is some way in which this user that's

play01:51

on your service is sending this file to

play01:53

your server usually this has more steps

play01:55

though usually it's more like this where

play01:58

the user will send

play02:00

some type of like permission request to

play02:03

make sure they have permission to

play02:04

actually do this thing so which the

play02:06

server applies yes you can

play02:09

upload and then and only then do we

play02:12

actually send the file to your server in

play02:15

order for this to work you have to have

play02:17

authentication checks at all of these

play02:18

steps and once this permission has been

play02:20

granted you probably have to REO too

play02:22

because you want to make sure that this

play02:23

is actually the person doing the upload

play02:25

but you have to have some level of back

play02:26

and forth here on top of that it's

play02:28

important to recognize the size of of

play02:30

these requests the permission request is

play02:31

probably going to be like literally 1

play02:33

kilobyte the response will probably also

play02:35

be 1 kilobyte the file upload might be

play02:38

50 megabytes so now your service is

play02:40

eating 50 megabytes of egress where

play02:42

you're passing this to your server we

play02:44

even talked about the other side though

play02:46

which uh honestly probably better to

play02:47

have a different shape I'll use uh our

play02:49

good old Diamond to represent external

play02:51

services in this case S3 this is the

play02:54

file storage on Amazon that most people

play02:56

are using for actually storing their

play02:57

files once this file has been uploaded

play02:59

you you probably want to pass it to S3

play03:01

so it's there forever so we're uploading

play03:03

the file and then we have to Route this

play03:05

through your service and then over to S3

play03:08

so we have to eat the cost of ingesting

play03:10

the file as well as passing it over we

play03:12

have to wait till the whole file has

play03:13

uploaded have it on our server and then

play03:15

pass it if this file is too big good

play03:17

luck there's a lot of things you have to

play03:19

think about when you do this wouldn't it

play03:21

be really nice if instead of the file

play03:23

upload happening here you could just

play03:25

have it go straight to S3 wouldn't that

play03:27

solve a lot of these problems it

play03:29

introduces own problems too which is

play03:30

that your server needs to know when the

play03:32

upload is done so once S3 is done

play03:34

ideally it's going to call your service

play03:36

and say by the way upload completed

play03:39

because something has to tell your

play03:40

server when the upload is done believe

play03:42

it or not the way most Services work is

play03:44

they'll actually have the user tell the

play03:47

server hey I just finished uploading

play03:49

because getting S3 to tell your server

play03:51

that the uploads complete is way more

play03:53

annoying than it should be the main

play03:55

thing I want to talk about here though

play03:56

is this skipping the step straight to S3

play03:59

usually what will happen here is you'll

play04:01

contact us three or do your own things

play04:03

to sign to create what's called a

play04:05

pre-sign poost URL which is what gets

play04:07

sent back here you signed post sent the

play04:10

pre-sign post URL is a URL that was

play04:12

generated by your server that allows for

play04:14

a user within a specific window with

play04:16

specific permissions and like file

play04:18

delimiters to then upload that file

play04:20

straight to S3 so you'd request to your

play04:22

server hey I want to upload a thing I

play04:24

want to upload an image up to 4

play04:26

megabytes your server then responds to

play04:28

that user with the presign post URL that

play04:30

they then post the image to to send it

play04:31

to S3 pre-sign post is just the way we

play04:34

do this for a bunch of reasons largely

play04:36

because skipping your server means the

play04:38

Ingress and the egress costs in and out

play04:40

get entirely eliminated and the latency

play04:42

is much better too because the user is

play04:44

posting straight to S3 instead of going

play04:45

through a middleman that said pre-sign

play04:47

post URLs leave a lot of places to make

play04:49

mistakes which is probably what this

play04:51

post is focused on back to said post so

play04:53

you might have recently seen Eva's

play04:55

tweets about S3 upload and how many

play04:57

companies can't stop messing it up

play04:58

believe it or not this a much more

play05:00

widespread issue than even my tweets

play05:01

made it out to be check out Eva's

play05:02

Twitter if you haven't already XYZ Eva

play05:04

absolute Legend killing it with these

play05:06

xpls and security discoveries I've

play05:08

learned a lot from watching them so

play05:09

check them out anyways this article

play05:11

covers two common vulnerabilities that

play05:13

they found within S3 uploads

play05:15

specifically within pre-signed posts who

play05:17

doesn't love a good cross-site script

play05:19

xss everyone's favorite you probably saw

play05:21

this one coming companies make a files.

play05:23

some company.com or CDN Doom company.com

play05:26

subdomain for S3 and when you combine

play05:28

that with poor handling of content types

play05:30

of an uploaded endpoint we can upload

play05:32

HTML files and if their cookies are set

play05:34

in properly we can use this to take over

play05:36

accounts this is scary the piece you

play05:39

need to know in order for this to make

play05:41

sense is that HTML and JavaScript tags

play05:44

that are served from a specific URL have

play05:46

access to the cookies from that domain

play05:48

so if you set a cookie on google.com and

play05:52

you serve some HTML on google.com/

play05:54

whatever that HTML when it runs in the

play05:57

browser has access to the cookies that

play05:58

are on that base URL if you set your

play06:01

cookies in correctly you might also have

play06:03

those on all your subdomains so if you

play06:05

set your cookies where they work on

play06:06

files. google.com as well as on

play06:08

google.com like the root domain now if

play06:11

you put an HTML page on files.

play06:13

google.com and someone can open it you

play06:14

have access to things that you shouldn't

play06:16

have access to that is very very scary

play06:19

for security reasons it's one of the

play06:20

first things that people look for when

play06:21

they're trying to exploit Services

play06:23

because now if you are able to upload

play06:25

files somewhere you shouldn't and they

play06:27

can be HTML Pages you can send one of

play06:29

those links like files.

play06:32

google.com/ my page. HTML if in here I'm

play06:35

doing some nasty stuff with cookies and

play06:37

Google's cookies aren't configured

play06:38

correctly I now have access to all of

play06:40

your off credentials and I can now take

play06:42

over your account cross- site scripting

play06:44

is one of the scariest ways to exploit

play06:46

things and now we're seeing just why

play06:48

well soon we will see just why and what

play06:50

is possible when you use these exploits

play06:52

the first example Eva gave was a website

play06:54

called tally Tally's a modern Google

play06:55

forms alternative which allows form

play06:57

Creation with images for this reason

play06:59

they also have profile pictures they

play07:01

need to store files that makes sense if

play07:03

you have a form that has images you need

play07:05

able to store images they chose a custom

play07:06

is endpoint that uploads a file for you

play07:09

to their S3 after performing checks

play07:11

sounds good right not so fast here's

play07:13

what the request for uploading something

play07:15

looks like so here's the request API TSO

play07:19

upload block asset you get back a

play07:21

response you have the pixel image the

play07:23

name the URL storage. T.O and here's the

play07:27

image pink pixel. PNG image. PNG size 83

play07:30

I'm sure it's like just 83 bytes cool

play07:33

looks interesting but what if we tried

play07:34

an HTML file instead hello image source

play07:37

X on error alert one cool and now if we

play07:41

see this she was able to post xss HTML

play07:45

as an asset to this endpoint and get

play07:47

back xss HTML with the MIM type being

play07:50

correct this is a big deal because the

play07:52

MIM type being correct means that you

play07:54

can go to this page and your browser

play07:55

will treat it as HTML and potentially

play07:57

exploit it EV just pointed out that

play07:59

browsers will actually try to MIM sniff

play08:01

even if content type is set to something

play08:03

else so if you don't manually set your

play08:05

headers is the host of the service it's

play08:08

possible that your browser will assume

play08:10

it's HTML and try to run it anyways even

play08:12

if you set some other M type elsewhere

play08:14

so yeah be careful of that cool so now

play08:17

that it's uploaded let's see what she

play08:18

does here you can see Hello empty image

play08:21

tag that is broken but it didn't alert

play08:25

which means that something's getting

play08:26

trimmed it looks like it didn't work

play08:27

let's look at the Dom hm looks like

play08:29

tally sanitized our xss payload out so

play08:32

they kind of thought of this but it's

play08:34

likely not foolproof that's very

play08:36

interesting that they let you upload

play08:37

HTML they just try to sanitize it before

play08:40

it gets to the user to remove things

play08:41

like JS tags fun let's see how this

play08:45

works or more importantly how this gets

play08:47

exploited looks like it got sanitized so

play08:49

they thought of this yada yada on error

play08:52

fetch attacker URL script. then a text

play08:55

then doing some vals cool and then the

play08:57

xmlns is W3 .org this is forcing the XML

play09:01

parsing mode ooh this actually works

play09:03

this allows me or bad actor to get

play09:05

cross-site scripting on files. T.O which

play09:08

has the session cookie in scope but it's

play09:10

HTTP only how can we get the cookie when

play09:12

it's HTTP only very interesting oh ha

play09:16

thank you Eva for pointing that out it's

play09:18

not an HTML Doc it's an XML doc because

play09:21

they're uploading this as SVG XML very

play09:24

clever very clever these are the things

play09:27

where like if your service isn't

play09:28

accounting for it you're SC and if

play09:29

you're trying to DIY all these Solutions

play09:31

they're not going to work we'll talk

play09:32

about the easiest ways to work around

play09:34

these things in a bit and early warning

play09:35

this will include a couple self plugs so

play09:37

know that but for now XML SVG XML

play09:40

specifically seems like a good way to

play09:42

hack some JavaScript into a place where

play09:44

it doesn't belong and according to chat

play09:47

both Eva and neotherm a lot of places

play09:49

don't actually secure SVG uploads which

play09:51

is terrifying but sadly doesn't surprise

play09:53

me so how do we deal with the fact they

play09:56

files endpoint is only HTTP not https

play09:59

turns out that tally has an endpoint for

play10:00

us that lets us get an authentication

play10:02

token from a refresh cookie and its web

play10:04

app also needs this token for the API so

play10:06

this is intentional here's my final

play10:08

payload served by my web server refret

play10:10

this page with credentials included and

play10:13

then a. json. then await fetch attack or

play10:16

call back method post body headers

play10:18

content type window location replace

play10:21

to.so very

play10:24

interesting and here's what my silly

play10:26

little web server gets when someone

play10:28

clicks this link

play10:30

so here they get the full dump of this

play10:32

user's information when somebody goes to

play10:34

the page so if they send them that SVG

play10:36

and they open it they get all of this

play10:38

sent over afterwards the do replace is

play10:41

just a cleanup so that it looks like you

play10:42

just went to the T homepage it's not

play10:44

actually important very good to

play10:46

know authorization token no oh Eva

play10:51

organization id never change never

play10:55

change love this full pwned cool one

play10:57

click full pone of your t account isn't

play10:59

that just really good well no Bounty was

play11:01

awarded for this I can't blame them

play11:03

they're a startup and they still fix the

play11:04

issue very quickly but as you can see

play11:07

these exploits are very powerful so

play11:09

obviously Eva continued S3 paths are

play11:12

tasty some Services allow the user to

play11:14

control the path and key of the file to

play11:16

upload while uploading common libraries

play11:18

also do this next S3 upload oh boy don't

play11:21

tell me the next S3 upload library is

play11:23

this easily compromised interesting this

play11:26

is a problem when the server doesn't

play11:27

check if the file already exists

play11:29

allowing the client to override other

play11:31

people's

play11:32

files I see where this one's going and

play11:34

this is again something that people

play11:36

every service I've seen gets wrong do I

play11:38

do the upload thing plug now or do I

play11:39

wait a little bit it's very tempting to

play11:41

plug upload thing right now but I'm

play11:42

going to wait for the time being we'll

play11:44

get to it in a bit I am sure exhibit B P

play11:47

yes I did choose the specific example to

play11:49

make it rhyme with

play11:51

t never change

play11:54

Eva anyways p is a way for streamers to

play11:57

set up a donation page and split it

play11:58

across their team such as their mods

play12:00

they have Channel banners and channel

play12:02

profile pictures so they need a way to

play12:03

store that data they chose to use S3 to

play12:05

do this here's what a request to upload

play12:07

an image would look like API p g V10

play12:09

upload sign ACL public read key is the

play12:12

key for the file and then file types

play12:14

image PNG I already am seeing the

play12:16

problem here my assumption before we go

play12:17

any further is that this key is

play12:19

something you're setting which means you

play12:20

can set this key to something that you

play12:22

shouldn't be able to upload and then

play12:23

override it then this returns a pre-sign

play12:26

post URL the key is randomly generated

play12:29

by the client so what happens if I

play12:31

change the key into something that's

play12:32

already used by another user well that's

play12:34

exactly what I did and it worked so for

play12:36

an entire minute Thor's profile picture

play12:38

on P was a gnome while watching pirate

play12:40

software for the Apex situation stream

play12:42

found this donation link with P found a

play12:43

way to override it basically it was just

play12:45

a classic case of insecured three

play12:46

uploads can I say on four yep but then

play12:48

here alternatively use something like

play12:50

upload thing to do the file uploads for

play12:51

you I'm going to take the opportunity

play12:53

here cuz you mentioned it first upload

play12:55

thing was built to solve a lot of these

play12:57

problems the number of places that I

play12:59

seen that are doing file uploads just

play13:01

like entirely incorrectly be it things

play13:03

like this be it eating egress cost and

play13:05

Ingress costs they shouldn't be eating

play13:06

be it just not authenticating on their

play13:08

servers properly be it allowing uploads

play13:10

that they shouldn't there are so many

play13:11

things I've seen like everyone get wrong

play13:13

including the naming of these things

play13:15

something that we do when we go to

play13:17

upload thing files or when you're

play13:19

uploading it in the first place if I

play13:20

just go to my T3 Gallery tutorials files

play13:23

all of these files have a key that we

play13:24

set and if you look at the URL you'll

play13:26

see the URL has this key in front front

play13:29

and then it has the PNG at the end when

play13:32

you save this file we're actually using

play13:34

other things to get the name that aren't

play13:36

included and this URL for the file is

play13:38

generated by us so there's no world in

play13:40

which you can override someone's file

play13:43

here it's just not viable you can't do

play13:45

it which is again really important and

play13:48

most people configure these things

play13:49

incorrectly that's why we did it so yeah

play13:51

if you want to set up these things

play13:53

correctly upload things really easy

play13:55

really cheap we have a guide on how to

play13:57

get started takes literal minutes to do

play13:59

some people it actually takes literal

play14:00

seconds to do we had a speedrun Content

play14:02

people were setting up upload thing in

play14:04

literally under 10 seconds on a new

play14:05

service while also being fully

play14:07

authenticated which is an important part

play14:09

we actually require with upload thing

play14:11

that you manage everything on your own

play14:13

service so if we see here this file

play14:15

router this is where you authenticate a

play14:17

user to upload this code runs on your

play14:19

server because we so strongly believe

play14:21

that you need to authenticate the users

play14:22

not us all of these patterns are things

play14:24

that we're strictly enforcing because

play14:26

most people do these things wrong so we

play14:28

just made them the default we made doing

play14:30

them correctly the default and as long

play14:32

as you scroll through and copy paste all

play14:33

this code it is very very hard to set up

play14:36

upload thing in a way that is unsafe by

play14:39

Design I also see some of the upload

play14:41

things speedrun winners hanging out in

play14:42

chat and bed set some insane scores on

play14:45

that speedrun embed just link their

play14:47

records upload thing speedrun of 9

play14:49

seconds and 245 milliseconds absolute

play14:52

Insanity there's a couple cheats here

play14:54

that let them do it so fast specifically

play14:56

that they use their bash history to fill

play14:57

out most of the back end code here but

play15:00

uh yeah that allowed them to set this up

play15:02

and get it working in literally

play15:05

seconds drag and drop the file go here

play15:08

and then you see it already uploaded

play15:10

actual

play15:11

Insanity so it should be that easy

play15:14

anyways setting this on the client is a

play15:16

terrible idea and I hope that by now you

play15:18

guys can understand why also allowing

play15:19

the user to set ACL is terrifying the

play15:21

results are not surprising either when

play15:23

you leave things like this accessible to

play15:25

the users terrifying they also didn't

play15:28

offer a bug but they're also a smaller

play15:30

startup so that's fair especially if

play15:31

they fixed it since like you're getting

play15:33

your value out of this blog post and

play15:35

again check out Eva if you haven't

play15:37

already she's good at this stuff you can

play15:39

probably pay her to pone your stuff and

play15:40

make sure you pay her for her efforts

play15:42

because she knows what she's doing and

play15:43

she deserves some money for it so how do

play15:44

we fix this we could simply avoid the

play15:46

examples above set your cookies properly

play15:48

and not allow people to control the key

play15:50

important stuff in conclusion S3 is

play15:53

pretty hard to do because of the common

play15:54

pitfalls people come across while using

play15:56

third party libraries specifically

play15:58

ignorance if you're using third- partyy

play15:59

libraries to manage your actual uploads

play16:01

it is pretty easy to do it wrong this is

play16:03

something that we've extensively covered

play16:05

in the past and S3's lack of good docs

play16:07

amplifies the issue I absolutely agree

play16:09

that's too hard though can somebody do

play16:11

it for me there's many products

play16:12

available to simplify S3 or redo it

play16:14

entirely here's a few pumped to be the

play16:16

first one in the list the B scale file

play16:17

upload API from what I've heard is

play16:19

pretty solid file stack I've heard a

play16:21

little bit about but I'm less familiar

play16:22

with uh simple file uploader and

play16:24

Powerful apis to upload transform and

play16:26

deliver things in your app cool haven't

play16:28

used this one so I don't know how good

play16:29

it is to recommend also their

play16:31

competition so I'm not going to linger

play16:32

on it too much but yes this is why we

play16:34

built upload thing we put a lot of work

play16:35

into it and I hope this video helps you

play16:37

understand exactly why managing your

play16:39

files is a scary thing and I see way too

play16:41

many people doing it wrong hopefully

play16:42

this incentivizes you to do it right and

play16:44

until next time peace nerds

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
S3 SecurityCloud StoragePre-Signed PostCross-Site ScriptingFile UploadsAuthentication ChecksEgress CostsIngress CostsSecurity Best PracticesWeb VulnerabilitiesUploadThing
¿Necesitas un resumen en inglés?