github orphan-oss/ognl OGNL_3_4_18
3.4.18

55 minutes ago

Security hardening: node guard

OGNL is an expression language and does not limit the time or memory an expression consumes.
expressionMaxLength limits the length of the expression text and nothing else. If your
application evaluates expressions that come from outside, restrict which language constructs
they may use.

This release adds NodeGuard for that. A guard is installed on the OgnlContext next to the
MemberAccess, and OGNL checks every node of a parsed expression against it before any part of
the expression is evaluated or compiled. A refused expression throws NodeNotAllowedException.

// refuse object and array construction and shifts
NodeGuard guard = NodeTypeGuard.denying(ASTCtor.class, ASTShiftLeft.class);
OgnlContext context = Ognl.createDefaultContext(root, memberAccess, classResolver, converter, guard);
  • NodeTypeGuard.allowing(...) is an allow-list and the safer choice for untrusted input:
    everything not listed is refused.
  • NodeVisitorGuard is a base class for rules that look at a node, built on the new NodeVisitor.
  • No guard is installed by default. Upgrading changes nothing until you install one.
  • A guard complements MemberAccess and does not replace it. Keep a restrictive MemberAccess
    that denies the ognl package.

See the Node Guard
section of the Developer Guide and the
security model.

Thanks to @arpitjain099, whose report led to this mechanism.

What's Changed

  • fix: apply member access and stricter invocation in compiled mode as in interpreted mode (3.4.x) by @lukaszlenart in #712
  • fix: box the whole numeric argument when compiling a call to an Object parameter by @lukaszlenart in #717
  • Backport #543, #723 and #724: compiled long and float literals keep their type (#720) by @lukaszlenart in #725
  • Keep the long and float literal suffix when a constant is coerced in a numeric expression by @lukaszlenart in #728
  • docs: state the release-line policy and freeze compiled mode on 3.4.x by @lukaszlenart in #740
  • [3.4.x] perf: skip the indexed property type lookup on plain chain links and cache the stricter-invocation class check by @lukaszlenart in #752
  • feat(runtime): backport the pluggable PropertyResolver to 3.4.x by @lukaszlenart in #761
  • [3.4.x] fix: let OgnlCache own every cache, so clearCache() empties them all by @alexmond in #762
  • [3.4.x] Make javassist optional: compiled mode becomes opt-in by @lukaszlenart in #764
  • [3.4.x] feat: add a visitor over the AST nodes by @lukaszlenart in #769
  • [3.4.x] feat: add a node guard to restrict the constructs an expression may use by @lukaszlenart in #770

Full Changelog: OGNL_3_4_17...OGNL_3_4_18

Don't miss a new ognl release

NewReleases is sending notifications on new releases.