fix: block eval of string BLOCK via template.new() (GH #245) - #418
fix: block eval of string BLOCK via template.new() (GH #245)#418toddr-bot wants to merge 1 commit into
Conversation
|
Recreated from #352 (auto-closed when the |
|
What do we need to do to help this one move along? Really looking forward to this change. |
|
@Koan-Bot review |
Fix logic sound. Two blockers: test payloads use |
|
|
Koan-Bot
left a comment
There was a problem hiding this comment.
Blocking issues found — see the review comment above.
Template authors could execute arbitrary Perl code by calling
template.new({BLOCK => '...'}) from within a template, bypassing
the EVAL_PERL security control. The eval happened in Document::new()
before the bless call, so side effects ran even though the method
ultimately failed.
Block string BLOCK (and DEFBLOCKS) eval when new() is called as an
instance method. The compilation pipeline always uses class method
calls, so this check has no impact on normal operation.
2914e40 to
df4d86b
Compare
|
Cool I see the new commit is up which should satisfy the "1 requested change" from "Koan-Bot"? What's next? |
|
@Koan-Bot review |
Yes. New commit resolves both blocking findings. Tests now use real eval-succeeding payloads. DEFBLOCKS bypass closed with second guard. Verified sole compile caller ( |
PR Review — fix: block eval of string BLOCK via template.new() (GH #245)Merge-ready. The revised commit resolves every blocking finding from the prior review; only two minor portability/clarity nits remain. What's solid:
🟢 Suggestions
1. DEFBLOCKS guard reuses the BLOCK error message
|
Koan-Bot
left a comment
There was a problem hiding this comment.
No blocking issues found.
What
Prevent arbitrary Perl code execution via
template.new({BLOCK => '...'})whenEVAL_PERLis disabled.Why
Fixes GH #245.
Template::Document::new()callseval $blockon string BLOCK arguments — this runs regardless of theEVAL_PERLconfig. Sincetemplateandcomponentare exposed as Document objects in the stash, a template author can calltemplate.new({BLOCK => 'malicious code'})to execute arbitrary Perl, bypassing theEVAL_PERLsecurity control entirely.The side effects run even though
new()ultimately fails (atbless), because theevalon line 80 fires before theblesson line 94.How
When
new()is called as an instance method (detected viaref $class), string BLOCK and DEFBLOCKS arguments are rejected with an error before anyevaloccurs. This blocks the template-side attack vector while preserving class method calls — the only legitimate compilation path.Testing
t/eval_perl_bypass.t:template.new()blockedcomponent.new()blockedQuality Report
Changes: 2 files changed, 122 insertions(+), 1 deletion(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan