Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

fix(server): validate and sanitize requested subdomains against RFC 1123 rules

Chiusa
#57 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend, security

Direzione di ricerca

Start in internal/server/server.go at registerSubdomain and trace how requested subdomains enter the tunnel registry. Add table-driven unit tests for valid and rejected inputs, covering normalization, RFC 1123 length and syntax, and reserved names. Done when the acceptance criteria pass and valid subdomains still register successfully.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Description

In internal/server/server.go (registerSubdomain), when a client supplies a custom req.Subdomain, it is accepted into the registry without sanitization:

func (s *Server) registerSubdomain(conn net.Conn, requested string) (string, error) {
    subdomain := requested
    if subdomain != "" {
        client := ClientConnection{...}
        if _, loaded := s.tunnels.LoadOrStore(requested, client); loaded {
            return "", fmt.Errorf("subdomain '%s' is already in use", requested)
        }
        return requested, nil
    }

Problem & Impact

  1. Namespace Hijacking & Squatting: A client can register reserved system names (such as api, admin, localhost, internal, dashboard, www, or the base domain itself).
  2. DNS & Routing Invalidation: A client can register subdomains containing dots (foo.bar), spaces, uppercase letters, slashes, or invalid punctuation, breaking public HTTP Host header matching and generating invalid URLs.
  3. HTTP Header & Log Injection: Malicious input containing control characters (CRLF) could corrupt logging or header serialization.

Proposed Solution

  1. Normalize requested subdomains to lowercase.
  2. Validate against RFC 1123 hostname rules: ^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$ (must be alphanumeric, hyphens allowed, 1–63 chars, no leading/trailing hyphens, no dots).
  3. Introduce a reserved subdomain blocklist (admin, api, localhost, www, root, etc.).

Acceptance Criteria

  • Reject any subdomain containing dots, spaces, uppercase letters, or special characters.
  • Enforce RFC 1123 length (1–63 characters).
  • Block reserved system keywords.
  • Add unit test table validating allowed and rejected subdomains.
Lingua principale
Go
Stelle
9
Fork
1
Merge medio
3h 29m
PR unite (30g)
29

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di kernelshard/expose

Tutte le issue di kernelshard/expose

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.