Skip to content

fix: patch SQL injection, command injection, and config injection vul…#159

Open
alexbelgium wants to merge 1 commit into
alexbelgium:mainfrom
7h30th3r0n3:fix/security-vulnerabilities
Open

fix: patch SQL injection, command injection, and config injection vul…#159
alexbelgium wants to merge 1 commit into
alexbelgium:mainfrom
7h30th3r0n3:fix/security-vulnerabilities

Conversation

@alexbelgium

Copy link
Copy Markdown
Owner

…nerabilities

  • play.php: Replace exec("sudo rm") with realpath() validation + unlink() to prevent OS command injection via deletefile parameter (CVSSv3 9.8)
  • play.php: Use parameterized query for filename lookup to prevent SQL injection
  • common.php: Convert all 3 query functions (fetch_species_array, fetch_best_detection, fetch_all_detections) from string interpolation to parameterized queries with bindValue()
  • config.php: Sanitize all user-controlled values written to birdnet.conf using whitelist patterns and numeric validation to prevent config injection leading to root RCE
  • todays_detections.php: Replace 5 concatenated LIKE clauses with parameterized bindings to prevent SQL injection via searchterm parameter

These fixes complement PR Nachtzuster#629 which addresses command injection in newname, shiftfile, sendtest, and species_delete. Together they close all 7 identified vulnerabilities.

Ref: Nachtzuster#608

…nerabilities

- play.php: Replace exec("sudo rm") with realpath() validation + unlink() to prevent
  OS command injection via deletefile parameter (CVSSv3 9.8)
- play.php: Use parameterized query for filename lookup to prevent SQL injection
- common.php: Convert all 3 query functions (fetch_species_array, fetch_best_detection,
  fetch_all_detections) from string interpolation to parameterized queries with bindValue()
- config.php: Sanitize all user-controlled values written to birdnet.conf using whitelist
  patterns and numeric validation to prevent config injection leading to root RCE
- todays_detections.php: Replace 5 concatenated LIKE clauses with parameterized bindings
  to prevent SQL injection via searchterm parameter

These fixes complement PR Nachtzuster#629 which addresses command injection in newname, shiftfile,
sendtest, and species_delete. Together they close all 7 identified vulnerabilities.

Ref: Nachtzuster#608

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba94c497dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/config.php
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=" . $safe_num($latitude), $contents);
$contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=" . $safe_num($longitude), $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=" . $safe($birdweather_id), $contents);
$contents = preg_replace("/APPRISE_NOTIFICATION_TITLE=.*/", "APPRISE_NOTIFICATION_TITLE=" . $safe($apprise_notification_title, '/[^a-zA-Z0-9._\- ]/'), $contents);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve notification template variables

When users follow the settings page guidance to put variables such as $comname or $confidence in the notification title, this whitelist removes the $ before writing birdnet.conf. The notification code later calls render_template() on the title, so a title like New $comname is saved as New comname and future alerts no longer include the detected species. Please preserve the supported $... tokens while still escaping the config value.

Useful? React with 👍 / 👎.

Comment thread scripts/play.php
Comment on lines +34 to +35
@unlink($file_pointer);
if (@unlink($file_pointer . ".png") || true) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fail deletion when the recording cannot be unlinked

If PHP/caddy lacks write permission on a restored or externally mounted recordings directory, the audio unlink() can fail, but || true makes the handler still return OK and then remove the database row. That leaves the recording orphaned on disk while the UI reports success; check the audio deletion result and only tolerate a missing PNG separately before deleting the DB row.

Useful? React with 👍 / 👎.

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