Set decryptionKey for legacy AES/3DES encryption #170
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.
Ysoserial.net incorrectly skips setting the decryption key for legacy framework versions using
TripleDES
orAES
validation algorithm, failing to generate a proper ViewState without--isencrypted
.If the target's framework version is .NET <= 4.0 and validation algorithm is either
TripleDES
orAES
, ViewState must be encrypted using a legacy algorithm. See this snippet fromSystem.Web.Configuration.MachineKeySection
forGetEncodedData()
method:As can be seen, the method explicitly checks for
TripleDES
orAES
validation algorithms to encrypt the payload. However, because ysoserial.net does not set the decryption key with--islegacy
argument not accompanied by--isencrypted
, it will generate ViewState encrypted withAutoGenerate,IsolateApps
key failing against the target using a static key.The target can still be exploited using
--islegacy --isencrypted
, placing ysoserial.net output into__VIEWSTATE
request parameter, and adding an empty__VIEWSTATEENCRYPTED
parameter to signify encryption.After fixing the issue, the target should also be exploitable by using
--islegacy
without--isencrypted
and placing ysoserial.net output into__VIEWSTATE
parameter and removing__VIEWSTATEENCRYPTED
parameter (ASP.NET assumes__VIEWSTATE
is encrypted for the above algorithms.)To fix this I suggest setting decryption key in all cases and letting .NET Framework do the choice of using it, since the above method seems to check for specific validation algorithms already.
This should resolve #122, #150 and #166.