dns/ddclient: DuckDNS token is written to syslog in clear text when the update request fails (native backend)

Aperta Adatta ai principianti
#5,863 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

La fuga si trova nel blocco except Exception della classe account DuckDNS in lib/account/duckdns.py, dove str(e) viene passato direttamente a syslog.syslog. Inizia confermando che l'URL della richiesta con il token raggiunge quel testo dell'eccezione. Poi intercetta l'errore e registra un messaggio che ometta l'URL o oscuri il valore della password. Il lavoro è completo quando un aggiornamento fallito non scrive mai il token in syslog e hai verificato se altre classi account in lib/account/ presentano lo stesso schema.

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

Descrizione

Important notices

Describe the bug

With the native backend, lib/account/duckdns.py sends the token as a query parameter
(requests.get(proto+'://www.duckdns.org/update', data)) and on any exception logs str(e):

except Exception as e:
    syslog.syslog(syslog.LOG_ERR, str(e))

For connection errors, requests includes the full request URL in the exception text, so the
log line contains the token in clear text, e.g.

HTTPSConnectionPool(host='www.duckdns.org', port=443): Max retries exceeded with url:
/update?domains=<name>&token=<TOKEN IN CLEAR TEXT>&ip=<ip> (Caused by ...)

The line is logged at LOG_ERR, so it also reaches every remote syslog target. Anyone who can read
the logs (locally or on the log server) can then repoint the DuckDNS name.

To Reproduce

  1. Configure a DuckDNS account in Services → Dynamic DNS (native backend).
  2. Make the first update fail at network level, e.g. right after a PPPoE reconnect before the
    line is ready (this is how we saw it, twice in the last eight weeks), or by temporarily blocking
    www.duckdns.org.
  3. Look at the system log / remote syslog: the ddclient error line contains token=....

Expected behavior

Credentials never appear in log output. For example, catch the exception and log without the URL,
or redact the token before logging:

except Exception as e:
    msg = str(e).replace(self.settings.get('password') or '\0', '***')
    syslog.syslog(syslog.LOG_ERR, f"DuckDNS update failed for {self.description}: {msg}")

(The dyndns2-based services are not affected: they send credentials via HTTPBasicAuth, so the
URL in an exception contains no secret. Other account classes that put secrets into the URL
may deserve the same check.)

Environment

  • OPNsense 26.7.8_1 (amd64)
  • os-ddclient as shipped with 26.7.8_1, native backend
Lingua principale
PHP
Stelle
1.2k
Fork
905
Merge medio
4g 19h
PR unite (30g)
16

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 opnsense/plugins

Tutte le issue di opnsense/plugins

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.