You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Mridul Pathak (Jira)" <ji...@apache.org> on 2026/09/04 16:12:00 UTC

[jira] [Closed] (OFBIZ-13522) Bind externalLoginKey to its intended destination webapps instead of validating against any webapp on the server

     [ https://issues.apache.org/jira/browse/OFBIZ-13522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mridul Pathak closed OFBIZ-13522.
---------------------------------
    Fix Version/s: Upcoming Branch
                   24.09.08
       Resolution: Fixed

> Bind externalLoginKey to its intended destination webapps instead of validating against any webapp on the server
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-13522
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-13522
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework/webapp, framework/widget
>    Affects Versions: Upcoming Branch, 24.09.07
>            Reporter: Mridul Pathak
>            Assignee: Mridul Pathak
>            Priority: Major
>             Fix For: Upcoming Branch, 24.09.08
>
>
> h3. Summary
> {{ExternalLoginKeysManager}} mints a single {{externalLoginKey}} per screen render and shares it across every cross-webapp link the render emits (see the hardening in [PR #1710|https://github.com/apache/ofbiz-framework/pull/1710], which made a key redeemable once per destination webapp rather than once globally). Each {{ExternalLoginTicket}} carries a {{targetContextPath}} field intended to scope a key to its intended destination webapp, but the only place a ticket is constructed, {{ExternalLoginKeysManager.getExternalLoginKey()}}, always passes {{null}} for it:
> {code:java}
> EXTERNAL_LOGIN_KEYS.put(externalKey, new ExternalLoginTicket(userLogin, null));
> {code}
> {{ExternalLoginTicket#isValidFor}} treats a {{null}} {{targetContextPath}} as "valid for any webapp":
> {code:java}
> boolean isValidFor(HttpServletRequest request) {
>     if (System.currentTimeMillis() > expiresAtMillis) {
>         return false;
>     }
>     return targetContextPath == null || targetContextPath.equals(request.getServletContext().getContextPath());
> }
> {code}
> As a result, a captured {{externalLoginKey}} (address bar, browser history, Referer header, proxy log) is redeemable once against *every* webapp reachable on the same OFBiz server within the 2-minute TTL, not just the webapps the page that minted it actually linked to. This includes webapps such as {{webtools}} that are deliberately excluded from the app-switcher navigation shown to a given user.
> h3. Fix
> Bind each minted key to the concrete set of destinations it is actually used for, instead of leaving it unbound:
> * Replace the single nullable {{targetContextPath}} on {{ExternalLoginTicket}} with a mutable allow-list of context paths, registered at the points where a concrete destination becomes known: {{WidgetWorker#buildHyperlinkUri}}'s {{inter-app}} branch, the duplicate {{inter-app}} branch in {{HtmlTreeRenderer#renderLink}}, and {{RequestHandler#makeLink}}'s {{targetControlPath}} branch.
> * For the app-switcher, which is built by theme {{.ftl}} templates concatenating hrefs directly (bypassing all Java link-building), pre-register the context roots {{WebAppCache#getAppBarWebInfos}} returns for the current server's {{main}}/{{secondary}} app-bar menus — the same data those templates already read — at the point {{ScreenRenderer}} exposes the key to the template context.
> * {{isValidFor}} becomes a strict allow-list check: a ticket is valid only for context paths explicitly registered on it, never "any webapp" by default.
> Acceptance criteria: a minted {{externalLoginKey}} redeemed against a webapp that was neither linked to on the originating render nor listed in that server's app-bar menus is rejected (falls back to the same not-auto-logged-in behavior as an expired key), while ordinary cross-webapp navigation (app-switcher, explicit inter-app links) continues to work exactly as before.
> h3. Backport
> The {{targetContextPath}} field this fix replaces was itself backported to release24.09 by [PR #1713|https://github.com/apache/ofbiz-framework/pull/1713]. Since release24.09 carries the same always-{{null}}, always-permissive field, it has the same gap and should get this fix too.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)