2020-01-23 23:21:38 ip-10-166-140-206.ec2.internal asyncio[11479] ERROR Task exception was never retrieved
future: <Task finished coro=<EC2Instances.fetch_all() done, defined at /home/ec2-user/ScoutSuite/ScoutSuite/providers/aws/resources/ec2/instances.py:14> exception=Error('Incorrect padding')>
Traceback (most recent call last):
File "/home/ec2-user/ScoutSuite/ScoutSuite/providers/aws/resources/ec2/instances.py", line 17, in fetch_all
name, resource = await self._parse_instance(raw_instance)
File "/home/ec2-user/ScoutSuite/ScoutSuite/providers/aws/resources/ec2/instances.py", line 26, in _parse_instance
instance['user_data'] = await self.facade.ec2.get_instance_user_data(self.region, id)
File "/home/ec2-user/ScoutSuite/ScoutSuite/providers/aws/facade/ec2.py", line 35, in get_instance_user_data
value = base64.b64decode(user_data_response['UserData']['Value'])
File "/usr/lib64/python3.7/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
it appears the code is not handling the missing ==== padding... just a guess.
Looks like the user data has invalid padding?
Guess we'll have to handle that case (looks easy enough https://gist.github.com/perrygeo/ee7c65bb1541ff6ac770) and handle exceptions (return None if decoding fails).
I added the exception handling and some code to try and decode the User Data by adding extra padding at the end of the Base64 string.
PR #653
We can close this issue now @j4v, right?