Skip to content
IDOR Write-up Beginner

The Form Said No, the API Said Yes: The Story of My Second CVE

The Kimai time-tracking application's API endpoint for saving user preferences did not check whether a preference was enabled for the user's role, allowing a low-privilege user to set their own hourly and internal billing rates. An attacker could alter the financial data used in invoices and timesheet exports.

udaypali134 Follow

Published on medium.com

Cve

Udaypali, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

Kimai is an open-source time-tracking application, with around 5.1k stars on GitHub at the time of writing. Teams use it to run timesheets, reports and the invoices that bill clients for that time. The feature at the centre of this write-up is the user preference store: a loose list of name/value pairs attached to each user, which includes billing fields such as hourly_rate and internal_rate.

What makes Kimai interesting from a security point of view is that it mixes permissions with money. Some users are allowed to set billing rates; most are not. The application knows this: when it builds a user's list of preferences, the role logic checks for the hourly-rate permission and, if the user does not have it, marks the field as disabled. The web form reads that flag and hides the field. The question the researcher asked was whether the field is off-limits everywhere, or only off-limits where the developer happened to be looking.

Setup

The testing was done with the weakest account available: a plain employee account with no special roles. No other accounts, versions or tooling preconditions are described beyond the following:

  • A local Kimai instance reachable at http://localhost:8001.
  • A standard user whose ID in the example is 2.
  • Burp Suite, used to capture the session cookie and send the request.

The CVSS vector requires any valid low-privilege account.

Finding it

The researcher started with the parts of the app that touch money. Logged in as the plain employee, they went looking for the hourly rate field on their own profile. It was not there: the form simply refused to show it, which is the application doing its job.

From the original on medium.com

The working rule carried over from a previous finding was that the frontend is a lie. A form that will not show a field does not prove the server will refuse it. A form is one door into a field, and rarely the only one.

Kimai exposes a REST API, so the next stop was the API documentation. There the researcher found a preferences endpoint:

Text
PATCH /api/users/{id}/preferences

Preferences are stored as a loose list of name/value pairs, and hourly_rate is one of them under the hood. That kind of flexible, catch-all endpoint is exactly where mass assignment bugs tend to hide. The hypothesis was straightforward: send the field the form would not allow, straight to the API, against the researcher's own account, and see whether the server would accept it.

Exploitation

Step 1: log in as an ordinary employee

Log into Kimai with an account that has no special roles. In the example the user ID is 2.

Step 2: capture the session cookie

Grab the session cookie from the browser (in this case via Burp Suite).

Step 3: PATCH your own preferences

Send a single PATCH request to your own preferences endpoint, setting the rates the UI would not let you touch:

Bash
curl -i -X PATCH "http://localhost:8001/api/users/2/preferences" \
  -H "Content-Type: application/json" \
  -H "cookie: <YOUR_STANDARD_USER_SESSION>" \
  -d '[
  { "name": "hourly_rate",   "value": "1337" },
  { "name": "internal_rate", "value": "1337" }
]'

The important parts:

  • The target is the caller's own user object (/api/users/2/preferences), so no cross-tenant or cross-user access is needed.
  • The body is a JSON array of name/value objects. hourly_rate and internal_rate are the two billing fields the form hides.
  • The session cookie belongs to the low-privilege account, so the request carries no elevated role.

Step 4: read the response

The server answers:

HTTP
HTTP/1.1 200 OK

The write succeeded. The sneaky part is that hourly_rate does not come back in the response. The same disabled flag that should have blocked the write does correctly hide the field on read, so at a glance nothing appears to have happened.

Except it did. The value was saved. The next time an admin opens that profile, or the user logs a timesheet, the billing rate in effect is whatever was set in the request. Write succeeds, read hides it, which is exactly how a bug like this sits unnoticed.

From the original on medium.com

Root cause

This is a mass assignment bug, formally Broken Object Property Level Authorization, CWE-915. In plain terms, the application lets a user write to a field they were never supposed to write to.

The root cause is two pieces of code that were supposed to agree and did not.

Kimai does know that a standard user should not touch hourly_rate. When it builds the list of preferences, the role logic checks for the hourly-rate permission and, if the user lacks it, marks the field disabled. The web form reads that flag and hides the field, which is why the UI looked locked down.

The API endpoint that saves preferences never checked that flag. The relevant code in src/API/UserController.php was:

Text
foreach ($request->request->all() as $preference) {        if (null === ($meta = $profile->getPreference($name))) {        throw $this->createNotFoundException(...);    }    $meta->setValue($value); }

It checks that the preference exists. It never checks that it is enabled for the calling user. The disabled flag is calculated perfectly and then thrown away the moment a write happens. One half of the application enforces the rule; the other half forgot to ask.

Impact

This is not a data breach. Nobody is reading secrets and nothing crashes. It is a business-logic flaw, and in an application that bills for people's time that is its own kind of serious.

A regular employee can set the billing rate that drives their own numbers. hourly_rate feeds straight into invoices and timesheet exports, so a low-privilege user can quietly change what their time is worth. Because the field is hidden from the normal UI, an admin has no reason to go looking. The result is invoices and reports that are wrong but look completely legitimate.

On the CVSS scale it comes out to 4.3, Moderate:

Text
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

The impact is real but bounded: network-reachable, low complexity, requires any valid low-privilege account, and needs no user interaction. Nothing leaks and nothing crashes; the whole impact lands on the integrity of the financial data.

Fix

The patch is almost as short as the exploit. In updateUserPreference, the maintainers added the one check that was missing: ask the flag before writing.

Text
if (!$meta->isEnabled()) {    throw $this->createAccessDeniedException('User tried to update preference: ' . $name);}

Now, if a user tries to set a preference their role has disabled, the API refuses with access denied instead of silently saving it. The maintainers also added a $dirty flag so the user is only saved when something really changed, plus two tests: one proving an admin can still set hourly_rate, and one proving a standard user is denied.

If you run Kimai, upgrade to 2.53.0 or later. If you cannot upgrade immediately, review who has accounts and audit user billing rates for unexpected values in the meantime.

Variants to test

  1. Other flexible preference or settings endpoints. Look for endpoints that accept a list of name/value pairs (preferences, settings, metadata, custom fields) and try writing a field the UI hides for your role. A positive result is a 200 OK where the field is absent from the response but present when an admin or a report reads it.
  2. Billing and rate fields on your own object. Try hourly_rate, internal_rate and similar money-related names against your own user, project or activity. A positive result is a saved value that later appears in invoices, exports or reports.
  3. The same field through a different door. Bulk import, impersonation and GraphQL are all separate write paths.
  4. Read-back asymmetry. After a write, check whether the field is hidden on read but still used downstream. A positive result is a field that never appears in your own view yet changes a number an admin sees.
  5. Role flag consistency. Compare the permission check used to build the form with the check used by the write endpoint. A positive result is a write endpoint that validates existence but not enablement, which is the exact shape of this bug.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

Kimai is a free, open-source time-tracking application. Teams use it to record the hours people work, produce reports, and generate the invoices that bill clients for that time. At the time of writing it had around 5.1k stars on GitHub, which is a rough public signal of how many people use and watch a project.

Because Kimai deals with time and money together, it has to be careful about who is allowed to set the money side of things. Some users are allowed to set billing rates, the amount a person's hour is worth. Most users are not. Kimai knows this: when it builds the list of settings for a user, it checks whether that user has the hourly-rate permission, and if they do not, it marks the field as disabled. The web page you see in the browser reads that mark and hides the field. So a normal employee never sees an hourly rate box on their own profile.

The question this write-up answers is simple to state: is that field off-limits everywhere, or only off-limits in the one place the developer happened to be looking? The answer turned out to be the second. The web form refused to show the field, but the application's programming interface, the API, accepted it anyway. A regular employee could send a single request and set their own billing rate to whatever they liked. That is the bug.

The setup

Kimai stores a loose list of settings for each user. Each entry in the list is a pair: a name, such as hourly_rate, and a value, such as a number. Two of those names matter here: hourly_rate, the rate used for billing, and internal_rate, an internal cost rate. Both are money fields, and both are meant to be controlled by people with the right permission, not by every employee.

The testing was done with the weakest account available: a plain employee account with no special roles. That matters, because it shows the bug does not need an administrator or any unusual access. The CVSS vector requires any valid low-privilege account.

The environment used was:

  • A local Kimai instance reachable at http://localhost:8001. "Local" means it was running on the researcher's own machine rather than on the internet, which is a common way to test software safely.
  • A standard user whose ID in the example is 2. Every user in an application like this has a number that identifies them.
  • Burp Suite, a tool that sits between the browser and the website and lets you look at, and change, the requests the browser sends. It was used to capture the session cookie and to send the request.

Finding it

The researcher started where they always start: the parts of the app that touch money. Logged in as the plain employee, they went looking for the hourly rate field on their own profile. It was not there. The form simply refused to show it, which is the application doing its job.

From the original on medium.com

The rule carried over from a previous finding was that the frontend is a lie. "Frontend" means everything that runs in your browser: the pages, the forms, the buttons. "The frontend is a lie" is shorthand for a habit of mind: just because a form will not show you a field does not prove the server will refuse it. A form is one door into a field, and rarely the only one. Think of a building where the front door is locked but a side entrance has been left open; the lock on the front door tells you nothing about the side entrance until you walk around and check.

Kimai exposes a REST API. An API is a way for programs to talk to an application without using its web pages. Where a human clicks buttons on a form, a program sends structured requests to addresses called endpoints, and gets structured answers back. "REST" is just a common style for organising those endpoints around resources, such as users or preferences. The API documentation listed a preferences endpoint:

Text
PATCH /api/users/{id}/preferences

This line says: to change the preferences of a user, send a request of type PATCH to the address /api/users/ followed by the user's number, followed by /preferences. PATCH is one of the standard request types; it means "change part of this thing". The {id} is a placeholder for whichever user number you mean.

Preferences are stored as a loose list of name and value pairs, and hourly_rate is one of them under the hood. That kind of flexible, catch-all endpoint, one that accepts any name you like, is exactly where mass assignment bugs tend to hide. Mass assignment means the application takes a bundle of names and values from the request and assigns them to its internal objects without checking whether the person sending them is allowed to set each one. It is like a hotel receptionist who accepts any instruction written on a guest's note, including "change the room rate", because the note is on the right form.

The hypothesis was straightforward: send the field the form would not allow, straight to the API, against the researcher's own account, and see whether the server would accept it.

Exploitation

Step 1: log in as an ordinary employee

Log into Kimai with an account that has no special roles. In the example the user ID is 2. The point of using the weakest account is to prove the bug works for the least privileged person in the system, not just for an administrator who could legitimately change rates anyway.

Step 2: capture the session cookie

Grab the session cookie from the browser, in this case via Burp Suite. A cookie is a small piece of text that a website asks your browser to store and send back with every request. After you log in, the site puts a session cookie in your browser, and that cookie is what tells the server who you are on each later request. It works like a wristband at an event: you show it once at the entrance, and after that the staff recognise you by the band rather than asking for your name every time. Anyone who has your cookie can act as you, which is why it is treated as a secret.

"Authentication" means proving who you are. No password is sent with the request; the cookie alone is enough.

Step 3: PATCH your own preferences

Send a single PATCH request to your own preferences endpoint, setting the rates the UI would not let you touch:

Bash
curl -i -X PATCH "http://localhost:8001/api/users/2/preferences" \
  -H "Content-Type: application/json" \
  -H "cookie: <YOUR_STANDARD_USER_SESSION>" \
  -d '[
  { "name": "hourly_rate",   "value": "1337" },
  { "name": "internal_rate", "value": "1337" }
]'

Line by line, in plain words:

  • curl is a command-line tool for sending requests to a server. It is the programmatic equivalent of typing an address into your browser, but it lets you control every part of the request.
  • -i tells curl to show the response headers as well as the body. Headers are the small labelled lines at the top of a response, such as the status code, and they are where you find out whether the request succeeded.
  • -X PATCH sets the request type to PATCH, the "change part of this thing" type described above.
  • "http://localhost:8001/api/users/2/preferences" is the address being called. localhost means this computer, 8001 is the port the local Kimai instance listens on, and /api/users/2/preferences is the endpoint for user number 2's preferences.
  • -H "Content-Type: application/json" is a header that tells the server the body is formatted as JSON. JSON is a simple text format for structured data, built from names and values in curly braces and lists in square brackets.
  • -H "cookie: <YOUR_STANDARD_USER_SESSION>" is the header that carries the session cookie. The placeholder stands for the real cookie value, which is a secret and is not reproduced here.
  • -d '...' is the body of the request, the actual data being sent. It is a JSON list of two objects. Each object has a name and a value. The first asks to set hourly_rate to 1337; the second asks to set internal_rate to 1337. 1337 is a well-known joke number among security people, standing in for "some value I chose".

The important parts of this request:

  • The target is the caller's own user object, /api/users/2/preferences, so no cross-user or cross-company access is needed. The attacker is not reaching into someone else's account; they are editing their own, which is why the request looks so ordinary.
  • The body is a JSON list of name and value objects. hourly_rate and internal_rate are the two billing fields the form hides.
  • The session cookie belongs to the low-privilege account, so the request carries no elevated role. Nothing in the request claims to be an administrator.

Step 4: read the response

The server answers:

HTTP
HTTP/1.1 200 OK

This is the status line of the response. HTTP/1.1 is the version of the protocol being spoken, and 200 OK is the status code. Status codes are three-digit numbers with agreed meanings; 200 means the request was understood and carried out successfully. Seeing 200 OK here is the moment the write succeeded.

The sneaky part is that hourly_rate does not come back in the response. The same disabled flag that should have blocked the write does correctly hide the field on read, so at a glance nothing appears to have happened. "On read" means when the application fetches and displays data, as opposed to "on write", when it saves data. The application was careful in one direction and careless in the other.

Except it did happen. The value was saved. The next time an admin opens that profile, or the user logs a timesheet, the billing rate in effect is whatever was set in the request. Write succeeds, read hides it, which is exactly how a bug like this sits unnoticed. Nobody sees an error, nobody sees a strange value in their own view, and the wrong number quietly flows into the places where money is calculated.

From the original on medium.com

Root cause

This is a mass assignment bug. The formal name is Broken Object Property Level Authorization, and it is catalogued as CWE-915. CWE is a public list of common weakness types, and each type has a number so people can refer to it precisely. In plain terms, the application lets a user write to a field they were never supposed to write to. "Authorization" means checking whether someone is allowed to do a particular thing, as opposed to authentication, which is checking who they are. Here the person was correctly identified as a low-privilege employee, and the application still let them do something that role should not permit.

The root cause is two pieces of code that were supposed to agree and did not.

Kimai does know that a standard user should not touch hourly_rate. When it builds the list of preferences, the role logic checks for the hourly-rate permission and, if the user lacks it, marks the field disabled. The web form reads that flag and hides the field, which is why the user interface looked locked down. A "flag" here just means a true or false marker stored alongside the field.

The API endpoint that saves preferences never checked that flag. The relevant code in src/API/UserController.php was:

Text
foreach ($request->request->all() as $preference) {        if (null === ($meta = $profile->getPreference($name))) {        throw $this->createNotFoundException(...);    }    $meta->setValue($value); }

In plain words:

  • foreach ($request->request->all() as $preference) means: take everything that arrived in the request, one item at a time, and handle each item.
  • if (null === ($meta = $profile->getPreference($name))) means: look up the preference by its name in the user's profile. If nothing is found, the result is null, which is the programming way of saying "nothing here".
  • throw $this->createNotFoundException(...) means: if nothing was found, stop and report that the thing does not exist.
  • $meta->setValue($value) means: otherwise, save the value that was sent.

It checks that the preference exists. It never checks that it is enabled for the calling user. The disabled flag is calculated perfectly and then thrown away the moment a write happens. One half of the application enforces the rule; the other half forgot to ask. It is like a building with a guard at the front desk who checks your name against a list, and a back door with a guard who only checks that the door exists.

Impact

This is not a data breach. Nobody is reading secrets and nothing crashes. It is a business-logic flaw, meaning the application does exactly what its code says, but the code does not match what the business intended. In an application that bills for people's time, that is its own kind of serious.

A regular employee can set the billing rate that drives their own numbers. hourly_rate feeds straight into invoices and timesheet exports, so a low-privilege user can quietly change what their time is worth. Because the field is hidden from the normal user interface, an admin has no reason to go looking. The result is invoices and reports that are wrong but look completely legitimate.

On the CVSS scale it comes out to 4.3, Moderate:

Text
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

CVSS is a standard scoring system for the severity of a security flaw. The string above is the score written out in its shorthand form, and each part means something:

  • AV:N means the attack can be carried out over a network rather than requiring physical access.
  • AC:L means the attack is of low complexity: no special conditions or lucky timing are needed.
  • PR:L means the attacker needs low privileges, in this case any valid low-privilege account.
  • UI:N means no user interaction is required; nobody has to be tricked into clicking anything.
  • S:U means the scope is unchanged: the flaw stays within the same security authority.
  • C:N means there is no impact on confidentiality, so nothing secret is exposed.
  • I:L means there is a low impact on integrity, so data can be changed but not in a sweeping way.
  • A:N means there is no impact on availability, so nothing is taken offline.

The impact is real but bounded: network-reachable, low complexity, requires any valid low-privilege account, and needs no user interaction. Nothing leaks and nothing crashes; the whole impact lands on the integrity of the financial data.

Fix

The patch is almost as short as the exploit. In updateUserPreference, the maintainers added the one check that was missing: ask the flag before writing.

Text
if (!$meta->isEnabled()) {    throw $this->createAccessDeniedException('User tried to update preference: ' . $name);}

In plain words:

  • if (!$meta->isEnabled()) means: if this preference is not enabled for the current user, then do the following. The exclamation mark means "not".
  • throw $this->createAccessDeniedException(...) means: stop and refuse the request with an access denied error, recording which preference was attempted.

Now, if a user tries to set a preference their role has disabled, the API refuses with access denied instead of silently saving it. The maintainers also added a $dirty flag so the user is only saved when something really changed, plus two tests: one proving an admin can still set hourly_rate, and one proving a standard user is denied. Tests matter here because they lock the behaviour in place, so a future change cannot quietly reopen the same door.

If you run Kimai, upgrade to 2.53.0 or later. If you cannot upgrade immediately, review who has accounts and audit user billing rates for unexpected values in the meantime. "Audit" here simply means going through the list and checking the numbers.

Variants to test

The lesson generalises. Here are the same ideas written as things to try on other applications:

  1. Other flexible preference or settings endpoints. Look for endpoints that accept a list of name and value pairs, such as preferences, settings, metadata or custom fields, and try writing a field the interface hides for your role. A positive result is a 200 OK where the field is absent from the response but present when an admin or a report reads it.
  2. Billing and rate fields on your own object. Try hourly_rate, internal_rate and similar money-related names against your own user, project or activity. A positive result is a saved value that later appears in invoices, exports or reports.
  3. The same field through a different door. Bulk import, impersonation and GraphQL are all separate write paths. Bulk import is a feature that loads many records at once from a file; impersonation is a feature that lets an administrator act as another user; GraphQL is another style of API.
  4. Read-back asymmetry. After a write, check whether the field is hidden on read but still used downstream. A positive result is a field that never appears in your own view yet changes a number an admin sees.
  5. Role flag consistency. Compare the permission check used to build the form with the check used by the write endpoint. A positive result is a write endpoint that validates existence but not enablement, which is the exact shape of this bug.

Glossary

  • API: a way for programs to talk to an application without using its web pages, by sending structured requests to addresses called endpoints.
  • Authentication: proving who you are, for example by logging in.
  • Authorization: checking whether the person who has been identified is allowed to do a particular thing.
  • Bulk import: a feature that loads many records at once from a file.
  • Burp Suite: a tool that sits between the browser and a website so you can inspect and change the requests being sent.
  • Business-logic flaw: a bug where the code does what it says but does not match what the business intended.
  • Cookie: a small piece of text a website asks your browser to store and send back with every request, often used to remember who you are after logging in.
  • CVE: a public identifier given to a specific security vulnerability so people can refer to it unambiguously.
  • CVSS: a standard scoring system for the severity of a security vulnerability.
  • CWE: a public list of common weakness types, each with a number.
  • CWE-915: the entry for mass assignment in that list.
  • Endpoint: a specific address in an API that performs a particular job, such as changing a user's preferences.
  • Flag: a true or false marker stored alongside something, such as whether a field is enabled.
  • Frontend: everything that runs in your browser, such as pages, forms and buttons.
  • GraphQL: another style of API, different from REST.
  • Header: a small labelled line sent with a request or response, carrying information such as the content type or the cookie.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • Impersonation: a feature that lets an administrator act as another user.
  • Integrity: the property that data has not been changed by someone who should not change it.
  • JSON: a simple text format for structured data, built from names and values in curly braces and lists in square brackets.
  • Mass assignment: a bug where an application takes a bundle of names and values from a request and assigns them without checking whether the sender is allowed to set each one.
  • Permission: a rule saying which users are allowed to do which things.
  • PATCH: a request type meaning "change part of this thing".
  • Port: a numbered channel on a computer that a service listens on, such as 8001.
  • REST: a common style for organising API endpoints around resources such as users or preferences.
  • Session cookie: the cookie that identifies you to a site after you log in.
  • Status code: a three-digit number in a response with an agreed meaning, such as 200 for success.
  • Timesheet: a record of the hours a person worked.
  • User interface (UI): the parts of an application a person sees and interacts with.
  • Write and read: a write saves data; a read fetches and displays it.

More by udaypali134

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.