wincred icon indicating copy to clipboard operation
wincred copied to clipboard

Lack of support for tokens over 2500 characters

Open jeremyjpaws opened this issue 3 years ago • 3 comments

Issue

There is a lack of support for wincred tokens over 2500 characters.

If more than 2500 characters are used, issues and errors such as "The stub received bad data" may occur when trying to authenticate against a container repository. See the related issues at (1,2,3).

Note that this maybe not quite a wincred bug directly, but a result of a limitation in the underlying Windows API and its credential store; however I am not sure in this.

References:

  1. https://github.com/aws/aws-cli/issues/5636
  2. https://github.com/docker/docker-credential-helpers/issues/190
  3. https://github.com/Azure/azure-cli/issues/4843

jeremyjpaws avatar Dec 29 '20 17:12 jeremyjpaws

Hi,

thanks for reporting this issue. I'll have a look immediately.

Cheers, Daniel

danieljoos avatar Dec 30 '20 13:12 danieljoos

Alright, this seems to be a limitation of the Windows API. The CRED_MAX_CREDENTIAL_BLOB_SIZE is 5 * 512 = 2560 Bytes. I haven't found any way to work around this limit. I tried to add a credential with more (~5k Bytes) in C++ and it failed with exactly the same error there, too.

The Windows API docs doesn't really mention it (or is wrong in this regards): https://docs.microsoft.com/en-us/windows/win32/api/wincred/ns-wincred-credentiala (See "CredentialBlobSize").

However, just printing out the value of CRED_MAX_CREDENTIAL_BLOB_SIZE in C++ revealed the 2560 Bytes limit. This is also the same value used in several other wrapper-projects, e.g. this one for Rust: https://bryal.github.io/d3d11-rs/winapi/wincred/constant.CRED_MAX_CREDENTIAL_BLOB_SIZE.html

danieljoos avatar Dec 30 '20 18:12 danieljoos

@danieljoos -- I haven't found any way to work around this limit. Possible workaround is using multiple credentials to store it

nick4fake avatar Jun 03 '21 10:06 nick4fake

A hint has been added to the README. Closing this issue.

danieljoos avatar May 16 '23 09:05 danieljoos