Dependency Injection
Unprotected CDNs
If the web application uses a third party server to retrieve resources such as scripts it is possible to attack the CDN and inject malicious code that is then executed in the page.
Identify the CDN server by reviewing the requests sent by the page. This can be done easily in the Network tab of the browser's development tool.
Verify server vulnerability
Use the following requests to verify if the CDN supports unauthenticated writing via PUT or POST methods
Options request
test unrestricted file upload
Code injection
Start local server
Useful functions to extract data
Payload to send data to our server
PUT request to replace resource with one containing our payload
Dependency confusion
This vulnerability arises when an application uses an internal package that is managed by a private repository. If we can upload our own package to the repository, during build time the python package manager will find duplicate packages and will pick the one with the latest version (this is why we upload a package with v9000 as version). This allows us to inject malicious code in the installer that will be executed by the package manager after retrieving our malicious package.
Package structure
Create standard python package structure
Configure setup.py
Compile and upload the package
Generate package and upload
Download package for testing or to transfer the payload on another compromised machine
Last updated