← Back to Baseline

MB-0796

Automated Custom source avoids enumerated raw crypto and session APIs

MB-C03 Secure Coding Practices Low

Collected custom PHP/PHTML contains no direct global session_start/session_id/session_regenerate_id/session_set_save_handler/mcrypt_encrypt/mcrypt_decrypt/md5/sha1/crypt/openssl_encrypt/openssl_decrypt call. This explicit coding restriction also bans legitimate non-security hash uses; it does not prove framework cryptography/session semantics. Scope is completely collected app/code PHP/PHTML; missing, unreadable, oversized, linked, malformed or truncated eligible input prevents a clean PASS.

Overview

Collected custom PHP/PHTML contains no direct global session_start/session_id/session_regenerate_id/session_set_save_handler/mcrypt_encrypt/mcrypt_decrypt/md5/sha1/crypt/openssl_encrypt/openssl_decrypt call. This explicit coding restriction also bans legitimate non-security hash uses; it does not prove framework cryptography/session semantics. Scope is completely collected app/code PHP/PHTML; missing, unreadable, oversized, linked, malformed or truncated eligible input prevents a clean PASS.

Why it Matters

Custom hash, crypto and session calls expose policy decisions that should have explicit ownership. A strict native-call restriction centralizes where those decisions are reviewed.

Some banned calls have legitimate non-security uses; a violation means the coding policy was broken, not that exploitation has been established.

Verification Steps

Manual Verification

  1. Review direct session_start/session_id/session_regenerate_id/session_set_save_handler, mcrypt, md5/sha1/crypt and openssl_encrypt/decrypt calls.
  2. Resolve aliases and indirect ambiguity.
  3. Separately assess approved services and key/session lifecycles.

Command / Review Sample

// Prohibited even for a non-security cache key under this policy:
$key = sha1($value);

Use the assessed Magento project and the appropriate application or read-only review account. Replace example hosts, paths and identifiers with the assessment scope; configuration and source fragments are illustrative.

Remediation / Fix Guidance

  1. Inspect each named call and argument at the reported file/line. Trace input origin, receiver identity, authorization and output use before deciding whether to replace the API or document an approved exception to this explicit coding policy.
  2. Test the affected behavior and its real trust boundary. Replacing an API or wrapping a call does not by itself validate input or remove an exploit path.
  3. Rerun MB-0796 against the same release, profile and relevant file/key/package scope; compare the new evidence and inspect any independent collection gaps.

Examples

Illustrative examples only. Interpret them within the current revision criterion above; missing collection evidence is unresolved, never PASS.

Fail Example

$key = sha1($value);
// Prohibited here even if this is a non-security use.

Pass Example

$ciphertext = $reviewedEncryptor->encrypt($plainText);
// Illustrative abstraction; separately review encryption/key semantics.

Scope and Evidence Limits

Rule revision: 1. Target modes: LOCAL.

Collected custom PHP/PHTML contains no direct global session_start/session_id/session_regenerate_id/session_set_save_handler/mcrypt_encrypt/mcrypt_decrypt/md5/sha1/crypt/openssl_encrypt/openssl_decrypt call. This explicit coding restriction also bans legitimate non-security hash uses; it does not prove framework cryptography/session semantics. Scope is completely collected app/code PHP/PHTML; missing, unreadable, oversized, linked, malformed or truncated eligible input prevents a clean PASS.

Exact opt-in coding policy, not a finding of confirmed exploitability or proof of the broader historical requirement. Runtime adapters, dependencies, generated code and files outside app/code remain outside this predicate.

Catalog coverage describes implementation capability, not a scan outcome. An incomplete manual review cannot establish that the criterion is satisfied.

References