Skip to content

Commit

Permalink
Add validation for URL domain in /artwork/generate endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptofyre committed Aug 9, 2024
1 parent 596e83f commit 8d83815
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ app.get('/artwork/generate', async (req, res) => {
if (!url) {
return res.status(400).send('URL query parameter is required');
}

const parsedUrl = new URL(url);
if (parsedUrl.hostname !== 'mvod.itunes.apple.com') {
logger.warn(`Invalid domain: ${parsedUrl.hostname}`);
return res.status(400).send('Only URLs from mvod.itunes.apple.com are allowed');
}

try {
const response = await fetch(url);
Expand Down

0 comments on commit 8d83815

Please sign in to comment.