Repository navigation
stats/teams: Use escaping instead of interpolation when building SQL - #1716
Merged
Merged
Conversation
chrismiceli
approved these changes
Nov 17, 2026
|
|
||
| if (!empty($_FILES['teamavatar']['tmp_name']) && ($type == "both" || $type == "avatar")) { | ||
| if (strtolower(substr($_FILES['teamavatar']['name'], -4)) == ".png" || strtolower(substr($_FILES['teamavatar']['name'], -4)) == ".jpg" || strtolower(substr($_FILES['teamavatar']['name'], -4)) == ".gif") { | ||
| $extension = strrchr(strtolower($_FILES['teamavatar']['name']), '.'); |
Collaborator
There was a problem hiding this comment.
should we use tools like pathinfo instead of manually parsing the string? I worry about things like evil.svg.jpg that may in certain contexts get interpreted as SVG with malicious Javascript or something. Maybe just enforce only one instance of . in the string as well as this extension check?
Collaborator
Author
There was a problem hiding this comment.
Yeah. We should use pathinfo. I ran across it later last night, and it turns out we parse filename extensions a few different ways in the codebase.
I specifically used strrchr to avoid the evil.svg.jpg scenario: it splits on the last . in the filename, but still, we may as well use pathinfo to avoid all doubt. I'll update the patch.
bpfoley
force-pushed
the
teams-escape
branch
2 times, most recently
from
November 17, 2026 21:04
2ced005 to
ef1b0ed
Compare
chrismiceli
approved these changes
Nov 17, 2026
srjfoo
approved these changes
Nov 18, 2026
As it turns out all the interpolated strings are integers or are entirely generated from code rather than user-controlled input, so this doesn't fix any exploitable issue, but it makes it clearer to static analysis tools and human readers.
Note, the semantics are slightly different
1. pathinfo's extension doesn't have the leading '.'
2. pathinfo's filename is just the filename and not the entire path
The patch accounts for the leading '.', and the list of files being
processed is generated by glob('*') which generates a simple list of
filenamess in the current directory (and no subdirs), with no path.
bpfoley
force-pushed
the
teams-escape
branch
from
November 22, 2026 20:33
ef1b0ed to
6945291
Compare
cpeel
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As it turns out all the interpolated strings are integers or are entirely generated from code rather than user-controlled input, so this doesn't fix any exploitable issue, but it makes it clearer to static analysis tools and human readers.