Security Enhancements: Implement rate limiting, whitelist ORDER BY and filter fields, replace os.execute() - #483
Open
cycomachead wants to merge 1 commit into
Open
cycomachead wants to merge 1 commit into
cycomachead wants to merge 1 commit into
Conversation
…d replace os.execute - Add rate limiting to the login endpoint to prevent brute-force attacks - Whitelist ORDER BY parameters and filter fields across controllers to prevent SQL injection - Replace shell-out `os.execute` and `io.popen` calls in `disk.lua` with LuaFileSystem to eliminate shell injection vectors - Restrict query field selection to internal controller sets instead of trusting request parameters https://www.superconductor.com/tickets/t7rHzQtzpFnH/implementations/KP7L7LQtmcNc#message_KtFCKpMk9tNH Co-authored-by: Claude Code <noreply@anthropic.com>
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.
Security Enhancements: Rate Limiting, SQL Injection Prevention, Shell Injection Removal
Implements four security fixes from a prior audit: rate limiting on login, whitelisting of
ORDER BYand filter parameters to prevent SQL injection, and removal of shell-out calls indisk.lua.Changes
rate_limit(self)to the login action incontrollers/user.lua, matching signup, password reset, and username reminder.order_by_clausehelper invalidation.luathat parses"column [ASC|DESC]", only allows columns in a per-controller whitelist, and returns a 400 on anything else. Applied tocontrollers/project.lua,controllers/collection.lua, andcontrollers/user.lua, each with a whitelist matching the sort options actually used by the UI/views.filter_clausehelper invalidation.luareplacing the old code that spliced anyfilter_*param name directly into SQL. Onlyverified,is_teacher, androleare accepted incontrollers/user.lua; values remain bound parameters, and empty values (the "Any" dropdown option) are now skipped instead of generating= ''comparisons.disk.lua: replaced allos.executecalls and theio.popen-basedstattimestamp lookup with LuaFileSystem (mkdir_p,copy_filepreserving mtimes,lfs.attributes). Removed the now-unusedstat_argumentsconfig value andSTAT_ARGSenv passthrough innginx.conf; addedluafilesystemas an explicit rockspec dependency.run_queryfunctions inproject.lua,collection.lua, anduser.luapreviously splicedself.params.fields(a client-controllable request param) into the SELECT list. Changed these to use an internalself.fieldsset only by controller code, and updated the corresponding server-side setters. No client code sendsfieldstoday.Notes for reviewers
locale.luastill contains oneos.execute('cp ...'), but the interpolated value is hardcoded toenin a dev-only tool, so it's not exploitable — left untouched.controllers/old/user.luais unused/unloaded and was not touched.disk.luabehavior (see commit history/conversation for details), not full end-to-end testing.Superconductor Ticket Implementation | App Preview | Guided Review