Elasticsearch password print on clear in case of error #14980

Closed
opened 2025-11-02 11:27:10 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @aarnaud on GitHub (Sep 24, 2025).

Originally assigned to: @shashank-netapp on GitHub.

Description

On startup if gitea failed to init it connection to ElasticSearch, the string connection containing the password is printed.

but we can see that is also masked on an other line.

In this example password is xyz

2025/09/24 16:39:18 .../indexer/issues/indexer.go:103:InitIssueIndexer.1() [F] Unable to issueIndexer.Init with connection http://gitea:xyz@indexer-gitea-es-http:9200 Error: health check timeout: Head "http://gitea:***@indexer-gitea-es-http:9200": EOF: no Elasticsearch node available

Gitea Version

1.24.5

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Inside Kubernetes

Database

PostgreSQL

Originally created by @aarnaud on GitHub (Sep 24, 2025). Originally assigned to: @shashank-netapp on GitHub. ### Description On startup if gitea failed to init it connection to ElasticSearch, the string connection containing the password is printed. but we can see that is also masked on an other line. In this example password is `xyz` ``` 2025/09/24 16:39:18 .../indexer/issues/indexer.go:103:InitIssueIndexer.1() [F] Unable to issueIndexer.Init with connection http://gitea:xyz@indexer-gitea-es-http:9200 Error: health check timeout: Head "http://gitea:***@indexer-gitea-es-http:9200": EOF: no Elasticsearch node available ``` ### Gitea Version 1.24.5 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Inside Kubernetes ### Database PostgreSQL
GiteaMirror added the type/bugtopic/security labels 2025-11-02 11:27:10 -06:00
Author
Owner

@shashank-netapp commented on GitHub (Sep 27, 2025):

Can this be assigned to me? I can have a look into it.

@shashank-netapp commented on GitHub (Sep 27, 2025): Can this be assigned to me? I can have a look into it.
Author
Owner

@lunny commented on GitHub (Sep 27, 2025):

You can move shadowURL from admin/config.go to modules/util and reuse it. And please also search other possible password leak logs.

@lunny commented on GitHub (Sep 27, 2025): You can move `shadowURL` from admin/config.go to modules/util and reuse it. And please also search other possible password leak logs.
Author
Owner

@shashank-netapp commented on GitHub (Sep 27, 2025):

Sure, thanks @lunny !!

@shashank-netapp commented on GitHub (Sep 27, 2025): Sure, thanks @lunny !!
Author
Owner

@shashank-netapp commented on GitHub (Sep 27, 2025):

@lunny, there's a function called SanitizeCredentialURLs under modules/util, which can be used here, without any cyclic import dependency. Any harm in using it ? rather than shadowURL ?

@shashank-netapp commented on GitHub (Sep 27, 2025): @lunny, there's a function called `SanitizeCredentialURLs` under `modules/util`, which can be used here, without any cyclic import dependency. Any harm in using it ? rather than `shadowURL` ?
Author
Owner

@lunny commented on GitHub (Sep 27, 2025):

SanitizeCredentialURLs will remove the the credentials as well as shadowURL will replace the password with *. Both are acceptable for me. If you move shadowURL to util. You need to do some adjustment like add a second return parameter error and remove the error log.

@lunny commented on GitHub (Sep 27, 2025): `SanitizeCredentialURLs` will remove the the credentials as well as `shadowURL` will replace the password with `*`. Both are acceptable for me. If you move `shadowURL` to `util`. You need to do some adjustment like add a second return parameter `error` and remove the error log.
Author
Owner

@wxiaoguang commented on GitHub (Sep 27, 2025):

SanitizeCredentialURLs does much better, more performant and well tested. shadowURL should be removed and replaced.

@wxiaoguang commented on GitHub (Sep 27, 2025): `SanitizeCredentialURLs` does much better, more performant and well tested. `shadowURL` should be removed and replaced.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14980