PrestaShop

Tip

Вивчайте та практикуйте AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Вивчайте та практикуйте GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Вивчайте та практикуйте Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Підтримайте HackTricks

Perl backticks/qx// sinks in Apache mod_perl handlers (досяжність та експлуатація)

Реальний зразок: код Perl будує рядок команд оболонки і виконує його через backticks (або qx//). У mod_perl AccessHandler компоненти запиту, контрольовані атакувальником, такі як $r->uri(), можуть потрапляти в цей рядок. Якщо будь-яка гілка конкатенує сирий ввід і потім виконує його через shell, ви отримуєте pre-auth RCE.

Ризикові примітиви виконання в Perl (породжують shell, коли їм передається єдиний рядок):

  • Backticks / qx//: my $out = cmd ...;
  • system with a single string: system(“/bin/sh -c ‘…’”) implicitly
  • open with a pipe: open my $fh, “cmd |” or “| cmd”
  • IPC::Open3 with a single string

Мінімальна вразлива форма, спостережена в реальному світі:

sub getCASURL {
...
my $exec_cmd = "...";
if ($type eq 'login') {
$exec_cmd .= $uri;        # $uri from $r->uri() → attacker-controlled
my $out = `$exec_cmd`;    # backticks = shell
}
}

Ключові міркування щодо досяжності в mod_perl:

  • Handler registration: httpd.conf must route requests into your Perl module, e.g. PerlModule MOD_SEC_EMC::AccessHandler and configuration that invokes AccessHandler::handler for a path scope.
  • Triggering the vulnerable branch: force the unauthenticated login flow so type == “login” (e.g., omit the expected auth cookie).
  • Resolvable path: ensure your request targets a URI that resolves within the configured scope. If Apache never routes the request through the handler, the sink isn’t reached.

Exploitation workflow

  1. Inspect httpd.conf for PerlModule/MOD_PERL handler scopes to find a resolvable path processed by the handler.
  2. Send an unauthenticated request so the login redirect path is taken (type == “login”).
  3. Place shell metacharacters in the request-URI path so $r->uri() carries your payload into the command string.

Example HTTP PoC (path injection via ‘;’)

GET /ui/health;id HTTP/1.1
Host: target
Connection: close

Поради

  • Спробуйте різні роздільники: ;, &&, |, backticks, $(…), and encoded newlines (%0A) залежно від quoting.
  • Якщо в ранніших патчах інші аргументи беруться в лапки, а URI — ні в одній гілці, payload-и, додані в кінці рядка, часто працюють: ;id# or &&/usr/bin/id#

Зміцнення безпеки (Perl)

  • Do not build shell strings. Prefer argument-vector execution: system(‘/usr/bin/curl’, ‘–silent’, ‘–’, $safe_url) — no shell.
  • If a shell is unavoidable, escape strictly and consistently across all branches; treat $r->uri() as hostile. Consider URI::Escape for paths/queries and strong allowlists.
  • Avoid backticks/qx// for command execution; capture output via open3/list form if truly needed without invoking a shell.
  • In mod_perl handlers, keep auth/redirect code paths free of command execution or ensure identical sanitization across branches to avoid “fixed everywhere but one branch” regressions.

Пошук вразливостей

  • Patch-diff modules that assemble shell commands; look for inconsistent quoting between branches (e.g., if ($type eq ‘login’) left unescaped).
  • Grep for backticks, qx//, open\s*(|||, and system\s*(\s*“ to find string-based shells. Build a call graph from sink to request entry ($r) to verify pre-auth reachability.

Реальний випадок: Dell UnityVSA pre-auth RCE (CVE-2025-36604)

  • Pre-auth command injection via backticks in AccessTool.pm:getCASURL when type == “login” concatenated raw $uri ($r->uri()).
  • Reachable through MOD_SEC_EMC::AccessHandler → make_return_address($r) → getCASLoginURL(…, type=“login”) → getCASURL(…, $uri, ‘login’).
  • Practical nuance: use a resolvable path covered by the handler; otherwise the module won’t execute and the sink won’t be hit.

Посилання

Tip

Вивчайте та практикуйте AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Вивчайте та практикуйте GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Вивчайте та практикуйте Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Підтримайте HackTricks