Skip to content

Fix AttributeError when parsing a credential with auth data#2219

Open
eugen-goebel wants to merge 1 commit into
fortra:masterfrom
eugen-goebel:fix-ccache-authdata-list
Open

Fix AttributeError when parsing a credential with auth data#2219
eugen-goebel wants to merge 1 commit into
fortra:masterfrom
eugen-goebel:fix-ccache-authdata-list

Conversation

@eugen-goebel

Copy link
Copy Markdown

Problem

Credential.authData is initialized as a tuple () and, unlike addresses, is never reassigned to a list before the parse loop runs self.authData.append(ad). Parsing any ccache credential that carries authorization data therefore raises:

AttributeError: 'tuple' object has no attribute 'append' (in Credential.__init__, impacket/krb5/ccache.py).

Closes #2119.

Fix

Initialize self.authData = [] right before the auth-data loop, mirroring the existing self.addresses = [] line a few lines above. Note: the issue also mentions addresses, but that attribute is already reassigned to a list before its own loop, so only authData was affected.

Test

Added a regression test in tests/misc/test_ccache.py that attaches an auth-data entry to a credential, serializes it, and parses it back. It fails on the current code with the AttributeError and passes with the fix. Full tests/misc/test_ccache.py: 6 passed.

Credential.authData was initialized as a tuple and never turned into a
list before the parse loop appended to it, so any ccache credential
carrying authorization data raised "AttributeError: 'tuple' object has
no attribute 'append'". Initialize it as a list right before the loop,
mirroring how addresses is already handled. Adds a regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ccache.py improper declaration of variables

1 participant