fix: code injection vulnerability in digest-bench#5
Draft
toddr-bot wants to merge 22 commits into
Draft
Conversation
Drop use vars
- meta-spec 2 resources format - dependencies are static, set dynamic_config 0 - EUMM will set configure_requires on itself - Test::More only used in tests - boilerplate to clean out unsupported keys if installed with old EUMM
Makefile.PL - use meta-spec 2, fix prereqs, compatibility with old EUMM
base.t, file.t: unlink temporary files created during testing
Ignore common temp files in repo.
eval "require $mod" allows arbitrary Perl execution when the module name is attacker-controlled. This test proves it by injecting code that creates a canary file after a valid require statement. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The eval-based require allowed arbitrary code execution when the module name argument contained injected Perl code (e.g., "Digest::MD5; system(...)"). Replace with the same safe pattern used in Digest.pm: convert :: to / in the module name and use bare require, which only loads files. Also declare $a with my to avoid clobbering the special sort variable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SECURITY —
digest-benchuseseval "require $mod"which allows arbitrary Perl code execution when the module name argument is attacker-controlled. This may warrant a vulnerability report.eval "require $mod"with safe barerequire(convert::to/, same pattern asDigest.pm)my $ainstead of clobbering the special$asort variableWhy
Line 8 of
digest-benchusedeval "require $mod"where$modcomes directly from@ARGV. An attacker (or careless user) could pass"Digest::MD5; system('rm -rf /')"and the injected code would execute inside the eval. The safe pattern used inDigest.pmitself (lines 42-47) converts::to/and uses barerequire, which only loads files and cannot execute arbitrary code.How
Two-commit approach per security flagging conventions:
Testing
digest-bench Digest::MD5still produces correct benchmark output🤖 Generated with Claude Code