Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

--generate-keys creates world readable private key (SYN-671) #1528

Closed
matrixbot opened this issue Apr 3, 2016 · 2 comments · Fixed by #16740
Closed

--generate-keys creates world readable private key (SYN-671) #1528

matrixbot opened this issue Apr 3, 2016 · 2 comments · Fixed by #16740
Labels
A-Packaging Our Debian packages, docker images; or issues relevant to downstream packagers S-Minor Blocks non-critical functionality, workarounds exist. Security T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution

Comments

@matrixbot
Copy link
Member

matrixbot commented Apr 3, 2016

... and hence so does the debian package.

Submitted by @​matthew:matrix.org

(Imported from https://matrix.org/jira/browse/SYN-671)

@matrixbot
Copy link
Member Author

My quick fix is something like this:

#!/bin/bash
USER="matrix-synapse"
GROUP="matrix-synapse"

PRIVKEYFILE=/etc/matrix-synapse/homeserver.tls.key
SIGNKEYFILE=/etc/matrix-synapse/homeserver.signing.key

if ! getent group $GROUP >/dev/null; then
  addgroup --quiet --system $GROUP
fi

if ! getent group $GROUP | cut -d : -f 4 | grep $USER > /dev/null; then
    addgroup $USER $GROUP
fi

if [ -f $PRIVKEYFILE ]; then 
    chgrp $GROUP $PRIVKEYFILE
    chmod 640 $PRIVKEYFILE
fi

if [ -f $SIGNKEYFILE ]; then 
    chgrp $GROUP $SIGNKEYFILE
    chmod 640 $SIGNKEYFILE
fi

The key files get created by the init script using --generate-config if they don't exist. If there were an easy way to get tls_private_key_path and signing_key_path from the synapse.config module then the key permissions could be checked on every start.

-- Billiam Crashkopf

@matrixbot matrixbot changed the title debian pkg creates world readable private key :( (SYN-671) debian pkg creates world readable private key :( (https://github.com/matrix-org/synapse/issues/1528) Nov 7, 2016
@matrixbot matrixbot changed the title debian pkg creates world readable private key :( (https://github.com/matrix-org/synapse/issues/1528) debian pkg creates world readable private key :( (SYN-671) Nov 7, 2016
@richvdh richvdh added the A-Packaging Our Debian packages, docker images; or issues relevant to downstream packagers label Oct 15, 2019
@richvdh richvdh added Security T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. S-Minor Blocks non-critical functionality, workarounds exist. labels Jul 14, 2021
@richvdh richvdh changed the title debian pkg creates world readable private key :( (SYN-671) --generate-keys creates world readable private key :( (SYN-671) Jan 18, 2023
@richvdh
Copy link
Member

richvdh commented Jan 18, 2023

@richvdh richvdh added the Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution label Jan 18, 2023
@richvdh richvdh changed the title --generate-keys creates world readable private key :( (SYN-671) --generate-keys creates world readable private key (SYN-671) Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Packaging Our Debian packages, docker images; or issues relevant to downstream packagers S-Minor Blocks non-critical functionality, workarounds exist. Security T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants