AWS Lambda performance optimization - more than just increasing memory

AWS Lambda performance optimization - more than just increasing memory

Pretty good blog, but I have a quick question: are there any security implications of storing secrets in global state in between invocations?

No more so than storing it in global state in any other container, whether Fargate, or even on EC2.

That’s not to say there’s no risk. There may be unknown vulnerabilities which allow another actor to recover memory, even on a VM (e.g., Meltdown). But these issues apply equally to any other multi-user/virtual system, and are exceptionally hard to exploit in the real world.

If your application leaks the secret itself, it likely doesn’t matter when it’s initialized.

Exactly. On top of that, in Lambda you shouldn’t store user-specific secrets, like user session values, only the “generic ones”, like tokens to external services. It’s because you don’t have any assurance the user will come back to the same environment (no sticky sessions) or the environment will even exist on the user’s second request. Such values should be stored in external storage, like DynamoDB or ElastiCache.

With that in mind, there is a much lower chance of leaking user data by mixing up sessions by race conditions, like GitHub did recently. Of course, it may still happen, but not in the Lambda directly, rather on the level of communicating with external storages.