Skip to content
Access control Write-up Advanced

CVE-2022-0540 - Authentication bypass in Seraph

An authentication bypass in Jira's Seraph filter allowed unauthenticated access to certain administrative actions by appending a path parameter to the URL. An attacker could reach actions that should require login, and some plugins were vulnerable to further exploitation such as remote code execution.

Khoa Dinh Follow

Published on blog.viettelcybersecurity.com

Sorry for the late writeup. When the Advisory for CVE-2022-0540 was released, some of my reports were triaged and I was hyped.

Khoa Dinh (@_l0gg), on blog.viettelcybersecurity.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

Jira's authentication has been handled for a long time by Seraph, the core authentication mechanism described in Atlassian's Jira Architecture overview. The researcher decided to look at it precisely because it is old and there is no known bug against it. The bug that came out of that review is CVE-2022-0540, an authentication bypass in Seraph, disclosed in the Atlassian advisory of 2022-04-20.

The whole bypass rests on a disagreement between two components about how to read the request path. The Seraph filter decides which roles a request needs by looking at the request URI, while the WebWork dispatcher decides which action to run by looking at the servlet path. Those two strings are not always the same, and the gap between them is the vulnerability.

Setup

The write-up does not describe a lab, accounts or tooling beyond a debugger. The work was done by reading Jira's architecture documentation, following the call chains in the source, and stepping through requests in a debugger.

Finding it

The Seraph filter

Jira implements Seraph as the filter com.atlassian.jira.security.JiraSecurityFilter. Its doFilter() method calls the parent method.

The filter then uses the security config services to obtain the roles required for the request.

Three services implement this in Jira:

  1. JiraPathService: if the requested servlet path starts with /secure/admin/, it requires the admin role.
  2. WebworkService: reads the roles-required configuration of WebWork actions from actions.xml.
  3. JiraSeraphSecurityService: reads the roles-required configuration of WebWork actions from every plugin's atlassian-plugin.xml.

JiraPathService is straightforward. The interesting ones are WebworkService and JiraSeraphSecurityService.

The WebworkService.getRequiredRoles() code:

JiraSeraphSecurityService reaches the same logic through a longer chain:

  • JiraSeraphSecurityService.getRequiredRoles() ->
  • LoginManagerImpl.getRequiredRoles() ->
  • AuthorisationManagerImpl.getRequiredRoles() ->
  • WebworkPluginSecurityServiceHelper.getRequiredRoles()

The researcher noticed that WebworkService.getRequiredRoles() and WebworkPluginSecurityServiceHelper.getRequiredRoles() contain the same code.

Both take the substring after the last / in the request URI and use a mapper to find which action it is. For example, for the request URI /jira/secure/somerandomstringasdf/AdminConfigurationAction.jspa, the AdminConfigurationAction.jspa part is used as the key to find the action with the actionMapper, and then all roles required by that action's configuration are returned.

The WebWork dispatcher

JiraWebworkActionDispatcher is mapped to the servlet path pattern *.jspa. When it services a request it gets the action name from the request and uses a chain of action factories to create the action.

JiraWebworkActionDispatcher gets the action name by taking the substring from the last / to the last .jspa in the servlet path.

For a servlet path of /jira/secure/somerandomstringasdf/AdminConfigurationAction.jspa, the action name is AdminConfigurationAction.

The action factories chain:

The inconsistency

The Seraph filter uses getRequestURI to find required roles, but the WebWork dispatcher uses getServletPath to find the action name. While looking into the difference between the two, the researcher found a Stack Overflow answer explaining it.

getRequestURI does contain path parameters, such as the ;jsessionid=S+ID shown in the picture. After some debugging, the researcher found that getServletPath does not contain path parameters. So if a path parameter is appended to the URI, for example AdminAction.jspa;, Seraph cannot find any matching case in the actionMapper, while the WebWork dispatcher still resolves the action.

That is enough to bypass the Seraph filter. The remaining question was why nobody had found this for so long.

The problem after the bypass

In the debugger the request could be seen bypassing the Seraph filter, but authentication was still required.

Continuing the debug, the researcher found that when the action factories chain creates the action, it checks authentication again.

At that point the researcher was close to giving up. Then, reading the documentation for roles-required in Jira, it says a roles-required attribute can be added to the parent WebWork element, or to a child action element, or both.

Checking all the cases manually, the researcher found that if the roles-required attribute is added to the WebWork element but not to the action element, LookupAliasActionFactoryProxy will not be able to authorise the action request.

An example action in that situation is InsightPluginShowGeneralConfiguration.jspa;.

One more obstacle: SafeParameterSettingActionFactoryProxy checks the websudo status if the requested action is annotated with @WebSudoRequired.

The researcher presents these two checks as the reason the bug went unnoticed for a long time.

Exploitation

Step 1: the payload

The payload is a single character:

Seraph reads the request URI, so the last path segment it extracts ends with the semicolon and does not match any action in the actionMapper. The WebWork dispatcher reads the servlet path, which has the path parameter stripped, so it still resolves the intended action.

Step 2: pick a suitable action

The bypass only reaches actions that meet both conditions found above:

  1. The roles-required attribute is set on the parent WebWork element and not on the action element, so LookupAliasActionFactoryProxy does not authorise the request.
  2. The action is not annotated with @WebSudoRequired, so SafeParameterSettingActionFactoryProxy does not demand a websudo session.

InsightPluginShowGeneralConfiguration.jspa; is given as an example of an action that satisfies this.

Step 3: request the action unauthenticated

Send the request to the action with the semicolon appended, without a session. The Seraph filter finds no matching action, and the dispatcher resolves the action from the servlet path. The write-up does not include the full request or the response.

Root cause

The two components parse different strings. Seraph's role lookup uses getRequestURI, which includes path parameters, while JiraWebworkActionDispatcher uses getServletPath, which excludes them. Appending ; to the action name makes the two views diverge: Seraph sees a name that matches no action, while the dispatcher sees the real action name.

The second authorisation check inside the action factories normally catches this, but only for actions whose roles-required is declared on the action element itself. When the attribute is declared on the parent WebWork element, LookupAliasActionFactoryProxy does not authorise the request. Websudo, checked by SafeParameterSettingActionFactoryProxy for actions annotated with @WebSudoRequired, is a further barrier that limits which actions are reachable.

Impact

The bypass can reach WebWork actions whose roles-required is declared on the parent WebWork element and which are not annotated with @WebSudoRequired. The impact therefore depends entirely on which action is reached.

For plugins, the researcher lists some affected ones with their impact, noting that the list is incomplete and that most plugins in Atlassian's advisory were false positives, had no impact, or had a small install count. No detailed proof of concept is given for these; the researcher suggests building one.

Plugin Impact
WBS Gantt-Chart for Jira Pre-auth RCE (any Java code can be written with BeanShell)
Insight - Asset Management Bundled with Jira Service Management Server and Data Center; view and change Insight configuration, and RCE with object schema manager permissions by changing the Groovy script whitelist
sumUp for Jira Stored XSS (a template injection, but Jira blacklisted some Velocity packages)
SQL+JQL Driver SQL injection (very hard to exploit)

Fix

Jira versions 8.20.6 and 8.13.18 were released on 2022-02-14 with the fix. The write-up does not describe what the fix changed.

Variants to test

  • Append a path parameter such as ; to a .jspa action and request it without a session. A positive result is the action executing instead of a login redirect or an authorisation error.
  • Try other path parameters, for example a session identifier form such as ;jsessionid=..., on actions that require a role. A positive result is the same divergence between the role lookup and the dispatcher.
  • Enumerate plugin actions whose roles-required is declared on the parent WebWork element rather than the action element, and check whether they are annotated with @WebSudoRequired. Actions that are not annotated are the reachable ones.
  • Check actions that perform sensitive operations, such as configuration views and changes, for the conditions above. A positive result is unauthenticated access to configuration data or functionality.

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. 14 min read.

What happened, in plain words

Jira is a popular tool that teams use to track tasks, bugs and projects. Like any workplace application, it has a front door: before you can see or change anything, you have to log in, and different people are allowed to do different things. An administrator can change settings; an ordinary user cannot.

This article is about a flaw in that front door. A security researcher found that by adding one single character, a semicolon (;), to the address of a Jira page, he could make Jira's login check look at one version of the address while the part that actually runs the page looked at a slightly different version. The login check saw an address it did not recognise and found no matching action. The part that runs the page saw the real address and ran the page anyway. The result: the login check could be bypassed for certain actions.

The flaw is tracked as CVE-2022-0540. "CVE" stands for Common Vulnerabilities and Exposures: it is a public catalogue number given to a security bug so that everyone can refer to the same thing. The bug is an authentication bypass, which simply means getting past the login check without having the credentials you are supposed to need. It was fixed in Jira versions 8.20.6 and 8.13.18, released on 2022-02-14, and described in Atlassian's advisory of 2022-04-20.

The researcher's own account has a sad ending: several of the reports he filed around this bug were eventually marked out of scope, not eligible for a bounty, or duplicates, and he lost the motivation to finish the write-up for a while. He published it anyway, to keep a promise.

Background: the pieces you need to know

Before the details make sense, here are the basic ideas, explained from zero.

A web request and a URL. When you type an address into your browser, the browser sends a request to a web server. The address is a URL, and the part after the site name is called the path. In https://example.com/jira/secure/AdminConfigurationAction.jspa, the path is /jira/secure/AdminConfigurationAction.jspa. The server reads the path to work out which page or feature you are asking for.

A servlet and a filter. Jira runs inside a Java web server. A servlet is a small Java program that handles requests for a particular kind of address. A filter is a piece of code that every matching request passes through before it reaches the servlet, a bit like a security guard at the entrance of a building who checks your badge before letting you walk to the office you asked for. Jira's login guard is a filter called Seraph.

Authentication and authorisation. Authentication is proving who you are (logging in). Authorisation is deciding what you are allowed to do once you are known. This bug is about authentication being skipped, and about a second authorisation check that normally catches such mistakes.

Roles. A role is a permission level, such as "administrator" or "user". Jira stores, for each page or action, which roles are required to use it. The login guard's job is to look up that requirement and enforce it.

A session and a session cookie. When you log in, the server gives your browser a small piece of data called a session cookie, which the browser sends back with every later request so the server can recognise you. If a request arrives without a valid session cookie, the server treats you as a stranger. A path parameter such as ;jsessionid=... is a way of carrying a session identifier inside the address itself rather than in a cookie; it is an old technique that still appears in URLs.

WebWork and actions. Jira's pages are built with a framework called WebWork. Each page or feature is handled by an action, a Java class with a name, and the address of such a page ends in .jspa. For example, AdminConfigurationAction.jspa is the address of an action called AdminConfigurationAction. A component called the dispatcher receives the request, works out which action name it refers to, and creates and runs that action.

Plugins. Jira can be extended with add-ons called plugins. A plugin can add its own actions, and it declares the roles those actions need in a configuration file called atlassian-plugin.xml. Jira's own built-in actions are declared in a file called actions.xml.

A debugger. A debugger is a tool that lets a programmer pause a running program, step through it line by line, and inspect the values of variables at each moment. The researcher used one to watch how a request travelled through Jira.

Websudo. Jira has an extra confirmation step, called websudo, for particularly sensitive administrative operations: even an administrator has to re-enter their password shortly before doing them. Actions that need this are marked with an annotation, @WebSudoRequired. An annotation is a label attached to code that the framework reads and acts on.

The vulnerability class. This is an authentication bypass caused by inconsistent parsing: two parts of the same program read the same piece of text in two different ways. If one part is the security check and the other is the thing being protected, the difference between their readings becomes a gap an attacker can slip through.

Finding it

The Seraph filter

Jira's architecture documentation describes Seraph as the core authentication mechanism, and it has been in place for a long time. The researcher chose to look at it precisely because it is old and he knew of no bug against it: old, heavily used code is worth a fresh look.

Jira implements Seraph as a filter with the class name com.atlassian.jira.security.JiraSecurityFilter. Its doFilter() method, the method that runs for every request passing through the filter, calls the parent method.

The filter then asks the security configuration services which roles the request requires.

Three services do this work in Jira:

  1. JiraPathService: if the requested servlet path starts with /secure/admin/, it requires the admin role. This is a simple rule based on the address alone.
  2. WebworkService: reads the roles-required configuration of WebWork actions from actions.xml, Jira's own list of actions.
  3. JiraSeraphSecurityService: reads the roles-required configuration of WebWork actions from every plugin's atlassian-plugin.xml, so that plugin pages are protected too.

JiraPathService is easy to follow. The interesting ones are WebworkService and JiraSeraphSecurityService, because they have to work out which action a request is for before they can look up its roles.

The code of WebworkService.getRequiredRoles():

JiraSeraphSecurityService reaches the same logic through a longer chain of method calls:

  • JiraSeraphSecurityService.getRequiredRoles() ->
  • LoginManagerImpl.getRequiredRoles() ->
  • AuthorisationManagerImpl.getRequiredRoles() ->
  • WebworkPluginSecurityServiceHelper.getRequiredRoles()

Each arrow means "calls the next method". The researcher noticed that WebworkService.getRequiredRoles() and WebworkPluginSecurityServiceHelper.getRequiredRoles() contain the same code.

Both of them take the piece of text after the last / in the request URI and use a mapper to find which action it is. The request URI is the full path the browser asked for, exactly as it arrived. The actionMapper is the lookup table that maps an action name to its configuration. For example, for the request URI /jira/secure/somerandomstringasdf/AdminConfigurationAction.jspa, the AdminConfigurationAction.jspa part is used as the key to find the action with the actionMapper, and then all roles required by that action's configuration are returned. In plain words: the guard chops the address at the last slash, looks the remaining word up in a list, and reads off the permissions that word needs.

The WebWork dispatcher

JiraWebworkActionDispatcher is mapped to the servlet path pattern *.jspa. That means: any request whose path ends in .jspa is handed to this dispatcher. When it services a request, it gets the action name from the request and uses a chain of action factories to create the action. An action factory is a helper that builds the action object; a chain of them means each factory gets a chance to build or adjust it in turn.

JiraWebworkActionDispatcher gets the action name by taking the substring from the last / to the last .jspa in the servlet path.

The servlet path is the part of the address that the web server matched to the servlet, after the server has normalised it. For a servlet path of /jira/secure/somerandomstringasdf/AdminConfigurationAction.jspa, the action name is AdminConfigurationAction. Notice that the dispatcher strips the .jspa ending, while the guard kept it; that difference alone is harmless because the mapper handles both forms. The important difference comes later.

The action factories chain:

The inconsistency

The Seraph filter uses getRequestURI to find required roles, but the WebWork dispatcher uses getServletPath to find the action name. These are two different methods that return two different strings for the same request. While looking into the difference between them, the researcher found a Stack Overflow answer explaining it.

getRequestURI does contain path parameters, such as the ;jsessionid=S+ID shown in the picture. A path parameter is an extra piece attached to one segment of a path with a semicolon, and it is not part of the resource name; it carries information such as a session identifier. After some debugging, the researcher found that getServletPath does not contain path parameters: the server strips them before handing the path to the servlet. So if a path parameter is appended to the URI, for example AdminAction.jspa;, Seraph cannot find any matching case in the actionMapper, while the WebWork dispatcher still resolves the action.

That is enough to bypass the Seraph filter. The guard looks up AdminAction.jspa; in its list and finds nothing. The dispatcher looks at AdminAction.jspa, recognises the action, and runs it. The remaining question was why nobody had found this for so long.

The problem after the bypass

In the debugger the request could be seen bypassing the Seraph filter, but authentication was still required.

Continuing the debug, the researcher found that when the action factories chain creates the action, it checks authentication again. This is a second lock on the same door, and it was catching the request that had slipped past the first one.

At that point the researcher was close to giving up. Then, reading the documentation for roles-required in Jira, he found that a roles-required attribute can be added to the parent WebWork element, or to a child action element, or both. In other words, a plugin can declare the permission requirement in two different places in its configuration file: once for a whole group of actions, or once for each individual action.

Checking all the cases manually, the researcher found that if the roles-required attribute is added to the WebWork element but not to the action element, LookupAliasActionFactoryProxy will not be able to authorise the action request. The second lock only works when the requirement is written on the individual action; when it is written only on the parent group, the second check has nothing to enforce and lets the request through.

An example action in that situation is InsightPluginShowGeneralConfiguration.jspa;.

One more obstacle: SafeParameterSettingActionFactoryProxy checks the websudo status if the requested action is annotated with @WebSudoRequired. So an action that demands a fresh password confirmation is checked for websudo status.

The researcher presents these two conditions as the reason the bug went unnoticed for a long time.

Exploitation

Step 1: the payload

The payload is a single character:

A semicolon appended to the action in the URI acts as a path parameter. Seraph reads the request URI, so the last path segment it extracts ends with the semicolon and does not match any action in the actionMapper, meaning no roles are required. The WebWork dispatcher reads the servlet path, which has the path parameter stripped, so it still resolves the intended action. In everyday terms: the guard reads the name badge with a stray mark on it and cannot find it on the list, while the office door reads the same badge without the mark and opens.

Step 2: pick a suitable action

The bypass only reaches actions that meet both conditions found above:

  1. The roles-required attribute is set on the parent WebWork element and not on the action element, so LookupAliasActionFactoryProxy does not authorise the request.
  2. The action is not annotated with @WebSudoRequired, so SafeParameterSettingActionFactoryProxy does not demand a websudo session.

InsightPluginShowGeneralConfiguration.jspa; is given as an example of an action that satisfies this.

Step 3: request the action unauthenticated

Send the request to the action with the semicolon appended, without a session. The Seraph filter finds no matching action, and the dispatcher resolves the action from the servlet path. The write-up does not include the full request or the response.

Root cause

The two components parse different strings. Seraph's role lookup uses getRequestURI, which includes path parameters, while JiraWebworkActionDispatcher uses getServletPath, which excludes them. Appending ; to the action name makes the two views diverge: Seraph sees a name that matches no action, while the dispatcher sees the real action name.

The second authorisation check inside the action factories normally catches this, but only for actions whose roles-required is declared on the action element itself. When the attribute is declared on the parent WebWork element, LookupAliasActionFactoryProxy does not authorise the request. Websudo, checked by SafeParameterSettingActionFactoryProxy for actions annotated with @WebSudoRequired, is a further barrier that limits which actions are reachable.

Impact

The bypass can reach WebWork actions whose roles-required is declared on the parent WebWork element and which are not annotated with @WebSudoRequired. The impact therefore depends entirely on which action is reached: viewing a configuration page is bad, but running arbitrary code on the server is far worse.

For plugins, the researcher lists some affected ones with their impact, noting that the list is incomplete and that most plugins in Atlassian's advisory were false positives, had no impact, or had a small install count. No detailed proof of concept is given for these; the researcher suggests building one.

Plugin Impact
WBS Gantt-Chart for Jira Pre-auth RCE (any Java code can be written with BeanShell)
Insight - Asset Management Bundled with Jira Service Management Server and Data Center; view and change Insight configuration, and RCE with object schema manager permissions by changing the Groovy script whitelist
sumUp for Jira Stored XSS (a template injection, but Jira blacklisted some Velocity packages)
SQL+JQL Driver SQL injection (very hard to exploit)

A few of those terms deserve a plain explanation. Pre-auth RCE means remote code execution before logging in: an attacker can make the server run code of their choosing without any account. BeanShell is a tool that runs Java-like code, so if an attacker can feed it code, they can run it. Stored XSS means cross-site scripting where the malicious content is saved on the server and served to other users later. SQL injection means tricking a database by slipping database commands into input. Groovy is a programming language used in Jira plugins, and a whitelist is a list of things that are allowed.

Fix

Jira versions 8.20.6 and 8.13.18 were released on 2022-02-14 with the fix. The write-up does not describe what the fix changed.

Variants to test

  • Append a path parameter such as ; to a .jspa action and request it without a session. A positive result is the action executing instead of a login redirect or an authorisation error.
  • Try other path parameters, for example a session identifier form such as ;jsessionid=..., on actions that require a role. A positive result is the same divergence between the role lookup and the dispatcher.
  • Enumerate plugin actions whose roles-required is declared on the parent WebWork element rather than the action element, and check whether they are annotated with @WebSudoRequired. Actions that are not annotated are the reachable ones.
  • Check actions that perform sensitive operations, such as configuration views and changes, for the conditions above. A positive result is unauthenticated access to configuration data or functionality.

Glossary

  • Action: in Jira's WebWork framework, the Java class that handles one page or feature, addressed by a name ending in .jspa.
  • Action factory: a helper that builds an action object; a chain of them lets several helpers adjust the action in turn.
  • actionMapper: the lookup table that maps an action name to its configuration, including required roles.
  • Annotation: a label attached to code (such as @WebSudoRequired) that the framework reads and acts on.
  • Authentication: proving who you are, usually by logging in.
  • Authentication bypass: getting past a login check without the credentials you are supposed to need.
  • Authorisation: deciding what a known user is allowed to do.
  • BeanShell: a tool that runs Java-like code, which can be abused to run arbitrary code if fed attacker input.
  • CVE: Common Vulnerabilities and Exposures, a public catalogue number for a security bug.
  • Debugger: a tool that pauses a running program and lets a programmer step through it and inspect values.
  • Dispatcher: the component that receives a request, works out which action it refers to, and runs it.
  • Filter: code that every matching request passes through before reaching the servlet, often used for security checks.
  • Groovy: a programming language used in Jira plugins.
  • Path parameter: an extra piece attached to a path segment with a semicolon, such as ;jsessionid=..., carrying information that is not part of the resource name.
  • Plugin: an add-on that extends Jira with extra features and its own actions.
  • Pre-auth RCE: remote code execution before logging in; an attacker runs code on the server without an account.
  • Request URI: the full path the browser asked for, exactly as it arrived, including path parameters.
  • Role: a permission level such as administrator or user.
  • Seraph: Jira's core authentication mechanism, implemented as a filter.
  • Servlet: a Java program that handles requests for a particular kind of address.
  • Servlet path: the part of the address matched to the servlet, after the server has normalised it and stripped path parameters.
  • Session cookie: a small piece of data given to the browser at login and sent back with later requests so the server recognises the user.
  • SQL injection: tricking a database by slipping database commands into input.
  • Stored XSS: cross-site scripting where malicious content is saved on the server and served to other users later.
  • Websudo: Jira's extra password confirmation step for sensitive administrative operations.
  • WebWork: the framework Jira uses to build its pages and actions.
  • Whitelist: a list of things that are explicitly allowed.

More by Khoa Dinh

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.