False positive in Go / Golang context when logging using %T
- Lingua principale
- CodeQL
- Stelle
- 10.1k
- Fork
- 2.1k
- Merge medio
- 2g 15h
- PR unite (30g)
- 141
Descrizione
**Description of the false positive**
[The warning](https://github.com/developerproductivity/costpuller/security/code-scanning/2) is "Clear-text logging of sensitive information", but what is actually logged is the _type_ of the variable which holds the information and not the information itself.
CodeQL correctly determines that a variable potentially holding a piece of sensitive information is [referenced in a `log.Fatalf()` call](https://github.com/developerproductivity/costpuller/blob/517634a461440261d5f0e5a3ccab0326e32c69a0/cloudability.go#L214-L214), but it misses the fact that the reference is processed using a `%T` format specifier which will result in the log receiving the _type_ of the data and not the _value_ of the data:
```go
apiKeyPair, ok := apiKeyPairAny.([]any)
if !ok {
log.Fatalf("Error reading Cloudability API keypair, expected an array, found %T",
apiKeyPairAny)
```
**Possible workaround**
I'm hoping that the following will suffice to work around the problem, but it's ugly and really shouldn't be necessary!
```go
log.Fatalf("Error reading Cloudability API keypair, expected an array, found %v",
reflect.TypeOf(apiKeyPairAny).String())
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo l’alert CodeQL in cloudability.go intorno alla riga 214 e analizza come vengono interpretati la chiamata a log.Fatalf e il relativo argomento di formato %T. Verifica che il logging di un valore con %T non venga trattato come logging in chiaro del valore, mentre il logging del valore stesso rimanga coperto; il lavoro è concluso quando il falso positivo segnalato non viene più rilevato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go
- Ambito
- security
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100