Skip to content

Write the daemon port file as mode 0600 - #637

Open
SebTardif wants to merge 3 commits into
ivpn:developmentfrom
SebTardif:bugfix/port-file-mode
Open

SebTardif wants to merge 3 commits into
ivpn:developmentfrom
SebTardif:bugfix/port-file-mode

Conversation

@SebTardif

Copy link
Copy Markdown

PR type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other... Please describe:

PR checklist

  • I have read the CONTRIBUTING.md doc
  • The Git workflow follows our guidelines: CONTRIBUTING.md#git
  • I have added necessary documentation (if appropriate)

What is the current behavior?

Launch writes the daemon port file with os.Create. That uses the process umask, so on Linux the file can be mode 0644. The file contains the TCP port and the secret local clients must send with Hello. The directory for that file is created with os.ModePerm.

A private report of this was closed without a code change (GHSA-9vqc-pp5f-wmc9).

Issue number: N/A

What is the new behavior?

The port file is opened mode 0600, and Chmod(0600) runs again when the file already exists. Its directory is created mode 0700. TestWriteFileMode0600 checks that helpers.WriteFile with mode 0600 keeps those bits on Unix.

Does this PR introduce a breaking change?

  • Yes
  • No

The UI and CLI still read the same port:secret line. Other local users can no longer read it when the daemon runs as root.

Other information

Base is development. CONTRIBUTING.md names the integration branch develop; this repository's default branch is development.

os.Create used the process umask, so port.txt was world-readable
on Linux. Open it as 0600, chmod again in case the file already
existed, and create its directory as 0700.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Launch now calls writeServicePortFile. The test pre-creates the
file as mode 0644 and checks the writer leaves mode 0600 and the
port:secret line. helpers.WriteFile is not this path.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant