-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: remove XSS cleaner and remove XSS vulnerabilities
We've been mostly relying on the 3rd party xss cleaner to make sure user submitted content is clean. This PR fixes up any leftover holes in the bbcode parser that allow xss vulnerabilities, and as a result, the 3rd party library isn't needed anymore. It cleans responsibly by first, running `htmlspecialchars()` over the content, followed by validating any untrusted input used inside html attributes. It validates urls by returning them as redirects relying on the browser not supporting executable protocols (like `javascript:`).
- Loading branch information
Showing
15 changed files
with
100 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
database/migrations/2023_11_04_094036_htmlspecialchars_decode_bbcode.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
return new class () extends Migration { | ||
public function up(): void | ||
{ | ||
DB::table('articles') | ||
->lazyById() | ||
->each(function (object $article): void { | ||
DB::table('articles') | ||
->where('id', '=', $article->id) | ||
->update([ | ||
'content' => htmlspecialchars_decode($article->content), | ||
]); | ||
}); | ||
|
||
DB::table('messages') | ||
->lazyById() | ||
->each(function (object $message): void { | ||
DB::table('messages') | ||
->where('id', '=', $message->id) | ||
->update([ | ||
'message' => htmlspecialchars_decode($message->message), | ||
]); | ||
}); | ||
|
||
DB::table('playlists') | ||
->lazyById() | ||
->each(function (object $playlist): void { | ||
DB::table('playlists') | ||
->where('id', '=', $playlist->id) | ||
->update([ | ||
'description' => htmlspecialchars_decode($playlist->description), | ||
]); | ||
}); | ||
|
||
DB::table('posts') | ||
->lazyById() | ||
->each(function (object $post): void { | ||
DB::table('posts') | ||
->where('id', '=', $post->id) | ||
->update([ | ||
'content' => htmlspecialchars_decode($post->content), | ||
]); | ||
}); | ||
|
||
DB::table('private_messages') | ||
->lazyById() | ||
->each(function (object $privateMessage): void { | ||
DB::table('private_messages') | ||
->where('id', '=', $privateMessage->id) | ||
->update([ | ||
'message' => htmlspecialchars_decode($privateMessage->message), | ||
]); | ||
}); | ||
|
||
DB::table('torrents') | ||
->lazyById() | ||
->each(function (object $torrent): void { | ||
DB::table('torrents') | ||
->where('id', '=', $torrent->id) | ||
->update([ | ||
'description' => htmlspecialchars_decode($torrent->description), | ||
]); | ||
}); | ||
|
||
DB::table('requests') | ||
->lazyById() | ||
->each(function (object $request): void { | ||
DB::table('requests') | ||
->where('id', '=', $request->id) | ||
->update([ | ||
'description' => htmlspecialchars_decode($request->description), | ||
]); | ||
}); | ||
|
||
DB::table('users') | ||
->lazyById() | ||
->each(function (object $user): void { | ||
DB::table('users') | ||
->where('id', '=', $user->id) | ||
->update([ | ||
'about' => htmlspecialchars_decode($user->about), | ||
'signature' => htmlspecialchars_decode($user->signature), | ||
]); | ||
}); | ||
} | ||
}; |
Oops, something went wrong.