Skip to content

fix(security): Add integrity verification before chmod +x in btrace-perfetto skill#5297

Open
fix-it-felix-sentry[bot] wants to merge 1 commit intomainfrom
security/EME-1060-fix-download-exec-pattern
Open

fix(security): Add integrity verification before chmod +x in btrace-perfetto skill#5297
fix-it-felix-sentry[bot] wants to merge 1 commit intomainfrom
security/EME-1060-fix-download-exec-pattern

Conversation

@fix-it-felix-sentry
Copy link
Copy Markdown

Summary

This PR addresses a security finding where a file is downloaded and immediately made executable without verification.

Changes

  • Added validation to verify the downloaded trace_processor file is a valid executable before making it executable
  • Check file exists and has non-zero size using [[ -s ]]
  • Verify file type is executable using file command
  • Remove file and exit with error if validation fails
  • Only apply chmod +x after successful verification

Security Context

The original code pattern (curl ... && chmod +x) was flagged as a security risk because it could potentially execute malicious or corrupted downloads. While the download is from a trusted HTTPS source (get.perfetto.dev), adding integrity verification is a security best practice that aligns with OWASP guidelines for Software and Data Integrity.

References

Testing

This change affects documentation in a Claude Code skill file. The validation logic follows standard bash practices and will properly verify downloaded executables before making them executable.

🤖 Generated with Claude Code by fix-it-felix-sentry[bot]

…erfetto skill

Add validation to verify downloaded trace_processor file is a valid executable
before making it executable. This prevents potential execution of malicious or
corrupted downloads.

Changes:
- Verify file exists and has non-zero size
- Check file type to confirm it's an executable
- Remove file and exit with error if validation fails
- Only chmod +x after successful verification

Fixes: https://linear.app/getsentry/issue/EME-1060
Parent ticket: https://linear.app/getsentry/issue/VULN-1513

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 17, 2026

@github-actions
Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (security) Add integrity verification before chmod +x in btrace-perfetto skill by fix-it-felix-sentry[bot] in #5297

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Fixes

- Add integrity verification before chmod +x in btrace-perfetto skill ([#5297](https://github.com/getsentry/sentry-java/pull/5297))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against c7b4981

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 17, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.39.0 (1) release

⚙️ sentry-android Build Distribution Settings

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c7b4981. Configure here.

curl -sL "https://get.perfetto.dev/trace_processor" -o /tmp/trace_processor

# Verify the file is a valid executable (check file type and size)
if [[ ! -s /tmp/trace_processor ]] || ! file /tmp/trace_processor | grep -q "executable"; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fragile file check may reject valid executables

Medium Severity

The file ... | grep -q "executable" check is unreliable because get.perfetto.dev/trace_processor serves a Python wrapper script, not a native binary. The file command's inclusion of "executable" in its output for scripts depends on the system's file version and magic database — some implementations report shebanged scripts as "Python script, ASCII text" without the word "executable". Additionally, if Perfetto ever changes to serving native PIE ELF binaries, older Linux file versions (< 5.36) report them as "shared object" without "executable". In either case, the validation incorrectly deletes the valid download and exits with an error, breaking the entire workflow.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c7b4981. Configure here.

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.

0 participants