[ 
https://issues.apache.org/jira/browse/WW-5830?focusedWorklogId=1056247&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1056247
 ]

ASF GitHub Bot logged work on WW-5830:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Nov/26 15:32
            Start Date: 20/Nov/26 15:32
    Worklog Time Spent: 10m 
      Work Description: g0w6y commented on PR #2088:
URL: https://github.com/apache/struts/pull/2088#issuecomment-7043517010

   Thanks, all five points are addressed in fd2fde3e0:
   
   1. Already-encoded values are pinned for textfield (all themes), form 
onsubmit/onreset, doubleselect and optiontransferselect; the PR description now 
has an explicit **Breaking change** section with before/after and the migration 
step.
   2. `render()` clears the shared writer before each render; with the 
templates reverted, 13 of 14 tests fail (previously several stayed green).
   3. Negative assertions added (unencoded payload absent from title, onclick, 
onsubmit, onreset, doubleselect and optiontransferselect attributes) plus an 
exact count of one `onreset=` per theme.
   4. Removed the duplicate `onreset` from `simple/form-common.ftl` and from 
`html5/form.ftl`; `simple` keeps `form.ftl`'s copy and `xhtml` keeps its own 
block with the default. No expected-output fixture changed.
   5. The `optiontransferselect.ftl` guard now reads `doubleOnkeydown??`, and 
`testOptionTransferSelectEventsAreEscaped` asserts it.
   




Issue Time Tracking
-------------------

    Worklog Id:     (was: 1056247)
    Time Spent: 1h  (was: 50m)

>  FreeMarker UI templates write event-handler attributes (onclick, onsubmit, 
> ...) without HTML escaping
> ------------------------------------------------------------------------------------------------------
>
>                 Key: WW-5830
>                 URL: https://issues.apache.org/jira/browse/WW-5830
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 6.12.0, 7.0.0, 7.3.0, 7.4.0
>            Reporter: Gouri Sankar A
>            Priority: Minor
>             Fix For: 7.6.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> The simple, xhtml, css_xhtml and html5 templates write the values of 
> event-handler attributes (on*, doubleOn*, doubleAccesskey, the form 
> onsubmit/onreset and the xhtml tooltip onmouseover) inside <#outputformat 
> 'JavaScript'>${...}</#outputformat>. With FreeMarker 2.3.35 that output 
> format does not escape anything and also turns off the surrounding HTML 
> auto-escape, so these values are written raw. Every other attribute, for 
> example title, is escaped, and the javatemplates engine escapes onclick.
> Reproduction (main, against a running Struts Boot app): <@s.textfield 
> name="f" onclick="%\{payload}" title="%\{payload}"/> with the payload   x" 
> autofocus onfocus="alert(1)   renders, in all four themes:
>   title="x&quot; autofocus onfocus=&quot;alert(1)" onclick="x" autofocus 
> onfocus="alert(1)"
> The title value stays inside its attribute; the onclick value closes the 
> attribute and adds new ones.
> THREAT_MODEL 8.8 says a value a UI tag renders into an attribute is 
> HTML-escaped "under every bundled theme and rendering engine", with 
> exceptions only for escape/escapeHtmlBody and URL-valued attributes; section 
> 9 says a value the application hands to a framework tag is covered by 8.8.
> Scope: HTML escaping closes the attribute breakout. It does not make request 
> data safe inside JavaScript code or strings in a handler (a browser decodes 
> &#39; before the script runs). No default framework path feeding request data 
> to these attributes was found; exposure needs an application binding data 
> into one, for example onclick="%\{#parameters.x}".
> Affected versions: the wrappers (14 in simple/scripting-events.ftl) are 
> present in the 6.12.0, 7.0.0, 7.3.0 and 7.4.0 tags, by source inspection. The 
> rendering was only reproduced on main. The wrappers date from the WW-4972 
> work (3d20e8095, 35497649b).
> Fix: remove the outputformat wrappers on those attributes (8 templates). 
> Behaviour change: handlers containing ' & < > or " change byte-for-byte 
> (browser-equivalent); applications that hand-escaped quotes (for example 
> &quot;) to work around the raw output would be double-escaped. Suggested 
> release note: "Event-handler attributes (onclick, onsubmit, ...) rendered by 
> the bundled templates are now HTML-escaped; remove any manual pre-escaping of 
> quotes in values passed to them."
> Tests: new EventHandlerEscapeTest (5 of its 6 tests fail without the template 
> change); 17 existing fixtures updated (' becomes &#39;).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to