mirror of
https://github.com/R0m1k3/FlowReader.git
synced 2026-10-11 17:28:05 +02:00
sécurité : correctifs XSS, SSRF, CSWSH, rate-limit et durcissement
- XSS stocké (critique) : sanitisation bluemonday sur tous les endpoints d'articles (List, ListByFeed, Favorites, Search, Get), pas seulement Get - SSRF (élevé) : nouveau utils/safehttp.go (ValidateExternalURL + client durci via Dialer.Control, bloque IP privées/loopback/link-local/metadata, anti-DNS-rebinding et limite de redirections) appliqué à l'extracteur et au parser - WebSocket CSWSH (élevé) : politique same-origin + override WS_ALLOWED_ORIGINS - rate-limiting (moyen) : token-bucket en mémoire sur /auth/* - token de session retiré du corps JSON (json:"-"), livré uniquement par le cookie HttpOnly - cookie Secure correct derrière un reverse-proxy (X-Forwarded-Proto + override COOKIE_SECURE) - admin : interdiction de supprimer son propre compte - en-têtes de sécurité (nosniff, X-Frame-Options, Referrer-Policy, Permissions-Policy) Note : backend non compilé localement (pas de toolchain Go) ; à valider via Docker. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
10fdfdeccb
commit
3402e53954
11 files changed
+346
-23
No files matched your search
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/google/uuid"
|
||||
"github.com/michael/flowreader/internal/domain"
|
||||
"github.com/michael/flowreader/internal/utils"
|
||||
"github.com/mmcdole/gofeed"
|
||||
)
|
||||
|
||||
@@ -23,12 +24,9 @@ type FeedParser struct {
|
||||
|
||||
// NewFeedParser creates a new feed parser.
|
||||
func NewFeedParser() *FeedParser {
|
||||
client := &http.Client{
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
|
||||
return &FeedParser{
|
||||
client: client,
|
||||
// SSRF-hardened client: refuses to connect to private/internal addresses.
|
||||
client: utils.SafeHTTPClient(30 * time.Second),
|
||||
parser: gofeed.NewParser(),
|
||||
}
|
||||
}
|
||||
@@ -44,6 +42,11 @@ type ParsedFeed struct {
|
||||
|
||||
// Parse fetches and parses a feed URL.
|
||||
func (p *FeedParser) Parse(ctx context.Context, feedURL string, feedID uuid.UUID) (*ParsedFeed, error) {
|
||||
// Validate up-front (scheme + non-private host) before issuing the request.
|
||||
if _, err := utils.ValidateExternalURL(feedURL); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create request with context
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, feedURL, nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user