What happens if a web application is fetching its contents from an S3 bucket that has been made publicly writeable? Let's consider a scenario where you have a web application that loads all its contents (images, scripts, and so on) from an S3 bucket. If incidentally, this bucket has been made public to the world, an attacker can upload his malicious .js file to the S3 bucket, which will then be rendered by the web application.
For the purpose of demonstration, we will set up a very basic HTML page that links to a JavaScript file hosted on an S3 bucket:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--Link JavaScript---->
<script type="text/javascript" src="https://s3.us-east-2.amazonaws.com/kirit-bucket/vulnscript.js"></script>
<!--Vulnerable...