Sonar Cloud scan currently flags the code in the 3 separate places we make s3 requests with the following warning:
"S3 operations should verify bucket ownership using ExpectedBucketOwner parameter"
Note: this issue has existed for a long time in the code, and is only being caught now since we updated the Sonar Cloud token and the scan is working properly as of the last month
The error is basically telling us we are vulnerable to something called a "confused deputy" attack but in practice the bignbit pipeline only engages (or should only engage) with S3 buckets owned by the same account that the service is deployed to. Theoretically, there is a vulnerability in the sense that a compromised Harmony API could post malicious data to a bucket purporting to be our own, and then when we go to stream it in the process_harmony_results function within the handle_big_result lambda, it causes a problem.
The solution is that we need to obtain the account id associated with the bignbit deployment, either at runtime or via tfvars (which can then be passed as input to the lambda), and submit the expectedBucketOwner as our account id in all 3 places that we make s3 requests in the code.