Not using Binary::safe* functions for substr/strlen function
Several places in the codebase call raw strlen and substr instead of the project's byte-safe Binary::safe* or CryptoUtil::safe* helpers. If those raw functions behave as multibyte-aware variants, byte counts and offsets could be wrong, though the text does not show a concrete exploit.
- Fixed in 2 days
- Disclosed after 2 days
Several places in the code don't use Binary::safe* or CryptoUtil::safe* functions, but use raw functions instead (strlen/substr) which can act as mb_funcname instead (not count bytes for strlen/etc...)
$lockTo = substr($lockTo, 0, strlen($lockTo) - 1);
2. https://github.com/paragonie/airship/blob/58f96aa0e5002b60e74456502d9bfc9483d77b3d/src/Engine/Security/Util.php#L98 can be changed to use self::subString which use Binary::safeSubstr
\substr($mimeType, $p),
if (\substr($print, 0, 3) === 'tmp' || \substr($print, 0, 5) === 'files') {
$x = \strlen($this->session['dir']);
return \substr($current, $x + 1);
$x = \strlen($this->session['dir']);
return \substr($file, $x + 1);
echo \substr($fileList[$choice], $l), "\n";
7. https://github.com/paragonie/airship/blob/58f96aa0e5002b60e74456502d9bfc9483d77b3d/src/CommandLine/installer.php#L39 8. https://github.com/paragonie/airship/blob/58f96aa0e5002b60e74456502d9bfc9483d77b3d/src/CommandLine/manual_update.php#L40 9. https://github.com/paragonie/airship/blob/58f96aa0e5002b60e74456502d9bfc9483d77b3d/src/symlinks.php#L48 10. https://github.com/paragonie/airship/blob/4aa579c564383355ad3de111a746f14a07164dba/src/config/logger.php#L28 11. https://github.com/paragonie/airship/blob/0e9289553cdc538556d362faaee63be6cc534a0c/tools/hangar/src/Commands/Add.php#L62 12. https://github.com/paragonie/airship/blob/0e9289553cdc538556d362faaee63be6cc534a0c/tools/hangar/src/Commands/Add.php#L62 13. https://github.com/paragonie/airship/blob/0e9289553cdc538556d362faaee63be6cc534a0c/tools/hangar/src/hangar.php#L68 14. https://github.com/paragonie/airship/blob/7bb8d24487e127b2210ac7f1153df8153208c3b9/tools/hangar/src/Command.php#L168
strlen usage:
1. https://github.com/paragonie/airship/blob/ef2d4f725e5af2eae27fd919533d01b625d020b1/src/Cabin/Hull/Blueprint/Blog.php#L1080 2. https://github.com/paragonie/airship/blob/ef2d4f725e5af2eae27fd919533d01b625d020b1/src/Cabin/Hull/Blueprint/Blog.php#L1098 3. https://github.com/paragonie/airship/blob/58f96aa0e5002b60e74456502d9bfc9483d77b3d/src/Cabin/Hull/Landing/IndexPage.php#L43 4. https://github.com/paragonie/airship/blob/0e9289553cdc538556d362faaee63be6cc534a0c/tools/hangar/src/Commands/Help.php#L100 5. https://github.com/paragonie/airship/blob/0e9289553cdc538556d362faaee63be6cc534a0c/tools/hangar/src/Commands/Add.php#L60 6. https://github.com/paragonie/airship/blob/58f96aa0e5002b60e74456502d9bfc9483d77b3d/src/Cabin/Hull/Landing/BlogPosts.php#L85 7. https://github.com/paragonie/airship/blob/58f96aa0e5002b60e74456502d9bfc9483d77b3d/src/Cabin/Hull/Landing/BlogPosts.php#L147 8. https://github.com/paragonie/airship/blob/0e9289553cdc538556d362faaee63be6cc534a0c/tools/hangar/src/Commands/Autorun.php#L61 9. https://github.com/paragonie/airship/blob/0e9289553cdc538556d362faaee63be6cc534a0c/tools/hangar/src/Commands/Autorun.php#L81 10. https://github.com/paragonie/airship/blob/4aa579c564383355ad3de111a746f14a07164dba/src/config/logger.php#L26 11. https://github.com/paragonie/halite/blob/8980974467cd54c6d2bb4dd98b2f0e9838570549/autoload.php#L13
fix:
- change strlen usage to CryptoUtil::safeStrlen or Util::safeStrlen or Binary::safeStrlen or Util::stringLength across the codebase.
- change substr usage to Util::safeSubstr or CryptoUtil::safeSubstr or Binary::safeSubstr across the codebase.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code relies on raw strlen/substr instead of the project's byte-safe wrappers, so behaviour depends on whether those raw functions are overridden to be multibyte-aware.
Impact
String lengths or offsets could be computed incorrectly in affected code paths, but the text does not show a working exploit or any specific security consequence.
What the attacker needed
Access to the source code
The fix
The raw strlen and substr calls should be replaced with the project's safeStrlen and safeSubstr helpers across the codebase.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some programming languages have string functions that count characters rather than bytes, and mixing the two can give wrong lengths or cut strings in the wrong place. This report lists spots where the code uses the plain functions instead of the project's own byte-safe helpers. It is a code-quality and hardening note rather than a demonstrated attack.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.