REDHAT-BUG-2547112: High severity Handlebars Handlebars vulnerability
Handlebars provides the power necessary to let users build semantic templates. From 4.0.0 until 4.7.10, Handlebars lookupProperty returns Function.prototype.constructor before applying the prototype-access deny list because constructor is an own property of Function.prototype. When an attacker can render a controlled template with allowProtoMethodsByDefault enabled and an accessible function in the template context, the template can traverse from that function through its prototype to Function.prototype and then obtain the Function constructor through the own-property bypass. This permits attacker-controlled JavaScript to execute with the server application's privileges. This issue is fixed in version 4.7.10.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Handlebarsto a version that resolves this vulnerability.Fixed in 4.7.10
Event History
Frequently Asked Questions
What conditions are required for exploitation?
An attacker must be able to render a controlled Handlebars template, the application must have allowProtoMethodsByDefault enabled, and the template context must expose an accessible function. Under those conditions, the attacker can reach the Function constructor and execute JavaScript with the server application's privileges.
Are default Handlebars configurations affected?
The described exploit requires allowProtoMethodsByDefault to be enabled. The provided information does not indicate that configurations without this setting enabled are exploitable by this path.
What should be done if upgrading cannot happen immediately?
Disable allowProtoMethodsByDefault and prevent untrusted users from supplying or controlling templates. Also avoid exposing functions in template contexts where controlled templates may be rendered.
How can I determine whether an application is affected?
Check whether it uses Handlebars versions from 4.0.0 through 4.7.10, enables allowProtoMethodsByDefault, allows attacker-controlled template rendering, and provides accessible functions in template context. The issue is fixed in Handlebars 4.7.10.