Bezbednost: open redirect i kolačići bez Secure atributa
- _next parametar: sanitizacija preko url.Parse (Host+Scheme prazan = relativan URL) umesto ručnog string check-a koji CodeQL nije prepoznavao - Kolačići: dodat Secure atribut (true u produkciji, false u razvoju) na 4 mesta: ntech_sesija brisanje (auth.go, prijava.go), ntech_flash_greska postavljanje i brisanje (auth.go, dashboard.go)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -264,8 +265,12 @@ func (h *Handler) SacuvajPodesavanja(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
sledeci := "/podesavanja"
|
||||
if next := r.FormValue("_next"); strings.HasPrefix(next, "/") && (len(next) == 1 || (next[1] != '/' && next[1] != '\\')) {
|
||||
sledeci = next
|
||||
if next := r.FormValue("_next"); next != "" {
|
||||
if u, err := url.Parse(next); err == nil && u.Host == "" && u.Scheme == "" {
|
||||
if p := u.RequestURI(); p != "" {
|
||||
sledeci = p
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// backup podešavanja — pri neispravnom unosu javljamo jasnu grešku
|
||||
|
||||
Reference in New Issue
Block a user