Skip to content

Fix variable syntax and restrict output file permissions#35

Open
assisted-by-ai wants to merge 1 commit intoKicksecure:masterfrom
assisted-by-ai:claude/security-audit-UwAkR
Open

Fix variable syntax and restrict output file permissions#35
assisted-by-ai wants to merge 1 commit intoKicksecure:masterfrom
assisted-by-ai:claude/security-audit-UwAkR

Conversation

@assisted-by-ai
Copy link
Copy Markdown

This PR addresses two issues in the Tor Browser update scripts:

Summary
Two bug fixes improving code correctness and security in the update utilities.

Key Changes

  • Fixed variable existence check syntax in update-torbrowser: Changed [[ -v "${tb_skip_functions}" ]] to [[ -v tb_skip_functions ]] to properly test variable existence without quote expansion
  • Restricted output file permissions in version-parser: Changed file creation mode from 0o644 (world-readable) to 0o600 (owner-only) for improved security

Implementation Details

  • The bash variable syntax fix ensures the -v test operator correctly evaluates whether the variable is set, rather than testing the expanded variable name
  • The permission change prevents unintended access to the version parser output file, limiting read/write access to the file owner only

https://claude.ai/code/session_01AUkdbvpoC4YFpZXtaMTypQ

tb_run_function: Fix indirect variable test `[[ -v "${tb_skip_functions}" ]]`
which tested whether a variable named by the *value* of tb_skip_functions
existed, rather than testing tb_skip_functions itself. This allowed bypassing
any security function (including signature verification) by setting two
environment variables: e.g. `tb_openpgp_verify=1 tb_skip_functions=tb_openpgp_verify`.

version-parser: Tighten output file permissions from 0644 to 0600 to avoid
creating world-readable temp files before input validation completes.

https://claude.ai/code/session_01AUkdbvpoC4YFpZXtaMTypQ
Copy link
Copy Markdown
Contributor

@ArrayBolt3 ArrayBolt3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integrated the useful bit from this in ArrayBolt3@8b2832a.


tb_run_function() {
[[ -v "${tb_skip_functions}" ]] || tb_skip_functions=''
[[ -v tb_skip_functions ]] || tb_skip_functions=''
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted.

else:
try:
output_path.touch(mode=0o644, exist_ok=True)
output_path.touch(mode=0o600, exist_ok=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejected, this adds no additional security. (For one, this doesn't actually set a file mode, the output file already exists because it was created by version-validator and Path().touch() doesn't adjust file mode on files that already exist, and for two, knowing the version that the user actually downloaded is virtually useless info. The only scenario I can imagine this stifling an attacker is if they were trying to read this file to see if an MITM attack succeeded, and any attacker that can do that probably has already taken over the end-user's machine.)

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.

3 participants