larksuite / larksuite/oapi-sdk-python

Redact access_key and ticket from WebSocket lifecycle INFO logs

Aperta
#141 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
559
Fork
102
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Problem

Client._connect() and _disconnect() log the complete WebSocket connection URL at INFO level. The URL returned by the Lark WebSocket endpoint contains sensitive access_key and ticket query values, so normal lifecycle logs can disclose credentials to stdout, journals, or downstream log collectors.

The current default-branch code passes the original URL directly to both log calls:

  • logger.info(self._fmt_log("connected to {}", conn_url))
  • logger.info(self._fmt_log("disconnected to {}", self._conn_url))

Reproduce / evidence

Using only fictional values, suppose _get_conn_url() returns:

wss://msg-frontier.example.test/ws/v2?fpid=493&access_key=access-key-test-value&service_id=33554678&ticket=ticket-test-value

After a connection and disconnect, the INFO messages include both access-key-test-value and ticket-test-value verbatim. The same original URL is also correctly required by websockets.connect(); the connection input itself must not be changed.

I searched current issues, pull requests, and default-branch code for msg-frontier, access_key, ticket, connected to, redact websocket URL, and sanitize URL query. I did not find an issue or PR that covers redaction of both WebSocket lifecycle log messages.

Required fix

Please redact only the values of the access_key and ticket query parameters before formatting the connection and disconnection INFO messages, while preserving the original URL for connection state and websockets.connect().

The log-safe representation should preserve non-sensitive query parameters and enough endpoint context for diagnostics. Ideally it should also preserve query ordering, repeated parameters, percent-encoding, empty/value-less parameters, and fragments except for replacing the two sensitive values.

Please add regression tests proving that:

  1. neither lifecycle log contains the original access_key or ticket value;
  2. non-sensitive URL context remains visible;
  3. websockets.connect() receives the exact original URL; and
  4. both connection and disconnection logs use the redacted representation.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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.

Direzione di ricerca

Inizia da Client._connect() e _disconnect(), quindi esamina la struttura esistente del logging del ciclo di vita e dei test di regressione. Il lavoro è completato quando entrambi i messaggi INFO oscurano solo i valori di access_key e ticket, mantenendo il resto del contesto dell’URL, e websockets.connect() continua a ricevere esattamente l’URL originale.

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

Valutazione

Stack tecnologico
python
Ambito
security
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
78/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.