Nir
Nir

Reputation: 2639

Get “Padding is Invalid and cannot be removed” in ASP.NET

I'm seeing this error a lot in my log lately on my prod. I've searched over the net on this error. I saw some notes like this, this or this. The bottom line on all of them is that I should set machineKey. But I already have machineKey set! Like that:

<machineKey decryption="AES"
        validation="SHA1"
        decryptionKey="64 hex key"
        validationKey="other 64 hex key"/>

Also I'm on web farm server and my application is on asp.net 3.5.

I'm pretty hopeless about this problem =\ How can I solve this?

Thanks.

EDIT:

Here is a full log:

Time: 04/07/2011 19:52:25
MESSAGE: Padding is invalid and cannot be removed.
HTTP_REFERER: 
SOURCE: mscorlib
FORM: 
QUERYSTRING: d=iAY45pNWTDkOra20F86mL9NBCe-wjxevTFjlNNxafjqLF0Aug2JmvB-c_8JQN4XnDIU1UJTmY2MC1xuySMKscg2&t=633851453303086250
TARGETSITE: Int32 DecryptData(Byte[], Int32, Int32, Byte[] ByRef, Int32, System.Security.Cryptography.PaddingMode, Boolean)
STACKTRACE:    at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
   at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
   at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
   at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo)
   at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
   at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Upvotes: 1

Views: 715

Answers (1)

SLaks
SLaks

Reputation: 887807

A recent ASP.Net patch changed the encryption format.

Make sure that every server in the farm is fully updated.

Upvotes: 3

Related Questions