Skip to content

[Feature Request] Privacy in log files #439

Closed

Description

@codefaux

Describe the feature idea
Promote user privacy during diagnostic sessions by stripping username and URLs (and any other personally-identifying-information) from logs.

Additional context
I'm at times overly security-focused, but it's not a bad practice to prevent information from being accidentally revealed.

Activity

  1. G4PLS commented on Jun 25, 2025

    @G4PLS
    Member

    Could you tell me where URLs are being exposed? Username makes sense as they are basically always visible, especially when there is a stacktrace.

    But the username removal should be doable, for the URLs i would need more information

  2. changed the title [-]Privacy in log files[/-] [+][Feature Request] Privacy in log files[/+] on Jun 25, 2025
  3. codefaux commented on Jun 25, 2025

    @codefaux
    Author

    The URL I've personally noticed is exposed from the Home Assistant plugin. I'm not sure how many other plugins interact with user infrastructure in this way, so I'm not sure if there are other places.

    2025-06-19 20:35:40.542 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:264 - Connection refused by wss://hass.---redacted---:443/api/websocket?latest. Make sure 'websocket_api' is enabled in your Home Assistant configuration.
    2025-06-20 11:46:20.215 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:264 - Connection refused by wss://hass.---redacted---:443/api/websocket?latest. Make sure 'websocket_api' is enabled in your Home Assistant configuration.
    2025-06-21 12:16:23.861 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:16:23 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:16:36.904 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:16:36 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:16:49.938 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:16:49 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:17:02.964 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:17:02 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:17:15.990 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:17:15 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:17:29.012 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:17:29 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:17:42.041 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:17:42 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:17:55.064 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:17:55 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:18:08.121 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:18:08 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:18:21.150 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:18:21 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:18:34.208 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:18:34 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:18:47.272 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:18:47 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:19:00.333 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 19:19:00 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 12:19:37.657 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: [Errno -3] Temporary failure in name resolution
    2025-06-21 12:21:05.572 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: [Errno -3] Temporary failure in name resolution
    2025-06-21 13:10:48.115 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:264 - Connection refused by wss://hass.---redacted---:443/api/websocket?latest. Make sure 'websocket_api' is enabled in your Home Assistant configuration.
    2025-06-21 14:16:31.202 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 21:16:31 GMT', 'content-length': '0'} -+-+- b''
    2025-06-21 14:16:41.215 | ERROR    | de_gensyn_HomeAssistantPlugin.backend.home_assistant:_auth:270 - Could not connect to wss://hass.---redacted---:443/api/websocket?latest: Handshake status 502 Bad Gateway -+-+- {'alt-svc': 'h3=":443"; ma=2592000', 'server': 'Caddy', 'date': 'Sat, 21 Jun 2025 21:16:41 GMT', 'content-length': '0'} -+-+- b''
    

    These errors occur every time my Home Assistant service is down, at minimum. I haven't looked through other logs and I literally just purged the folder to make diagnosing less cluttered, go figure.

    Seems like a plugin log, so easiest would be for plugin developers to self-filter their logs but best practice would be for the logger itself to do the cleaning, reducing the onus on developers to remember to prune.

  4. G4PLS commented on Jun 25, 2025

    @G4PLS
    Member

    Maybe we can introduce something in the settings that is a list of "banned" words where you can just add words that you want to have removed.
    So while the log is then being written to the CLI/Log file those things get replaced beforehand. This way the end user has the most control of things that should be filtered

  5. G4PLS commented on Jul 2, 2025

    @G4PLS
    Member

    Just wanted to give a small update to you.
    As Im currently reworking the settings I have added the UI for the banned words! Currently they dont work yet but the UI is in place.

    Image

  6. mfutselaar commented on Jul 15, 2025

    @mfutselaar

    Relying on a "banlist" to block out passwords from logs is a terrible idea that begs to be exploited. You're basically allowing plain-text access to the passwords for anyone that has access to the configuration (through the software itself or by simply reading the configuration file).

    This is something plugin developers need to handle, the best you can do is look for query strings such as ?password=123 or &password=123, or when it comes to json search for things like {"password":"123"}.

  7. codefaux commented on Jul 16, 2025

    @codefaux
    Author

    I have to say, I agree that putting a nice concise list of things you don't want people to see, all in one file, is not my idea of a cleverly implemented security feature.

    I was hoping for more along the lines of, an intelligently written series of regex filters which apply basic security-minded logic to their filter sets.

    The software can determine my username, and auto-filter that out. That's cake.

    RFC3986 Appendix B provides a regex to process any URI, and nothing past the domain is likely to be sensitive -- but you could have an option to filter "domain" or "all" on URI references.

    Retrieving the hostname an d network domain should be relatively straight-forward, and a filter could be written to keep that out of logs.

    An IPv4 or IPv6 address is really easy to pick up, this could be an option to skip.

    ^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$

    (([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))
    

    ( ^^^^ IPv6 Regex. Yikes, but it seems functional)

    Filesystem paths are easy enough to notice and strip or at least obfuscate.

    All of these can be done without user attention.

    I don't think the idea of coming up with a list of everything important you want someone not to find is even necessary, as most of the things I don't want someone to find won't be in the logs in the first place.

  8. G4PLS commented on Jul 16, 2025

    @G4PLS
    Member

    We can just expand this list to just allow regex and normal strings

    Then what we could do is:

    1. Loop through the filter list
    2. Take the next element from the list
    3. Look if there is a match with the current filter
    4. If there is a match take note of the start and end index and proceed with 5.
    5. If there is no match go back to 2
    6. Replace the string starting from the start index to the end index with something else
    7. Log the new string

    I think the user should specify what filters they want as not everyone cares about safety, we could expand that system by having default filters that can be enabled/disabled (Like the regex for ipv4/6)

    @codefaux what do you think?

  9. G4PLS commented on Jul 16, 2025

    @G4PLS
    Member

    I also have to agree with @mfutselaar. Things like passwords etc should not be in logs anyways, this is something that plugin developers have to look out for.

    I also dont see a reason why plugin devs would print a password in the log except they forgot to remove that when doing local testing

  10. codefaux commented on Jul 16, 2025

    @codefaux
    Author

    @G4PLS - Any means at all of passing the string through the filter pool would be acceptable. Steps 1 thru 6 can be summarized as a "foreach-style loop iterating against the list of filters and replacing text where necessary"..the replacement could be as simple as ... or -REDACTED- or whatever, that's not the heart of the debate here.

    I agree that passwords/etc are unlikely to be in a log, but if I run a curl command manually, or publish an MQTT message, I may be forced to unexpectedly put the password in the plugin's fields somewherem and a generic plugin might not know I'm putting it there. Passwords/etc may wind up in logs. Plugin devs aren't likely to include them, but they seemingly are likely to not think about other things they shouldn't put in.

    Here's my bottom line though:

    Protections should not be gatekept behind knowledge.

    • 95% of users, yes even Linux users, will look at a Regex and -- even if they understand how Regex works -- will not be able to determine what it does.
    • Many users won't even know they SHOULD be careful with the contents of logs. A user shouldn't have to know they need to turn on a setting.
    • A user shouldn't have to understand how to author a regex, in order to be protected from data leakage.
    • They should just be safe, with privacy considerations made for them.

    There should be a default set of protections -- username, URI, filesystem, IP addresses -- which are default enabled.
    There should be a way to expand protections for users who have specific/unusual/unpredictable needs, and the knowledge to suit them.
    Yes you won't catch every case, but the idea is to minimize what the user must know/do, and allow them to cover the gap.

  11. G4PLS commented on Jul 16, 2025

    @G4PLS
    Member

    That is completely understandable, I think if I get the energy to do some additions I will go in and expand the feature by making everything into a "FilterRule" that can be enabled/disabled and has a name and the actual rule.

    Then I can provide some default rules that get setup once (Like determining the username and creating a rule for the username).

    As mentioned in the other issue I have no clue when im able to get to that as im working a lot on the SC rework and that is taking most of my energy at the moment

  12. codefaux commented on Jul 16, 2025

    @codefaux
    Author

    I hear you. I'm less presenting a list of expectations of you/of the immediate future, and more presenting what I would consider to be the guidelines I would expect of a developed product. It's best to know what you're painting before you get too much on the canvas, I believe some would say.

    I offer my help with this or the SC rework project, in testing or whatever capacity is feasible. Energy is definitely at a premium lately, things are getting awfully ....heavy, all around. Scary times.

    Checking out for now.

  13. G4PLS commented on Jul 17, 2025

    @G4PLS
    Member

    The points you are making are very valid, I wouldnt implement something if I wouldnt think that it makes sense.

    With the SC rework there will maybe be an announcement at some point but currently keeping it for myself as there is still lots to do before actually having a minimum running version.

  14. Core447 commented on Aug 11, 2026

    @Core447
    Member

    Added simple log redaction with d294cce. Won't catch everything but it's a start

  15. Core447 commented on Aug 11, 2026

    @Core447
    Member

    Will close this for now because I believe this change is enough. If you think otherwise pls reopen

  16. codefaux commented on Aug 11, 2026

    @codefaux
    Author

    Looks like a pretty good foundation. Can't say what more might conceptually be required without some time on the ground. Good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions