Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

@cx-andre-pereira cx-andre-pereira commented Jul 24, 2025

Closes #7093
Reason for Proposed Changes

  • The purpose of this query is to check all ECS:Task-Definition resources and guarantee that, within their Volumes.EFSVolumeConfiguration field, TransitEncryption is defined and set to "ENABLED". This will ensure Amazon EFS volume(s) have encryption for data at transit.

  • The query and all its test, currently, have syntax errors for the Volumes and EFSVolumeConfiguration fields; put simple the capitalization of character is inconsistent with official documentation which clearly declares the fields with this syntax. There are no analog naming schemes mentioned and these field´s naming is case sensitive.

  • While investigation the reason for this seemingly dysfunctional since inception query, it was made clear that it is analog to a terraform query "ECS Task Definition Volume Not Encrypted". In terraform the fields are named in lowercase and the adjustment for CloudFormation was never properly done. There was an attempt but it only updated the transitEncryption to TransitEncryption.

  • Furtermore there is currently another CloudFormation query that is doing a very similar scan even though it is unrelated to its name/purpose. The "ECS Cluster Not Encrypted At Rest" query , which got updated recently as of writing (PR), is doing a near identical check except for the fact that it will only check the relevant ECS:Task-Definition resources, if they are referenced by an ECS:Service resource in its TaskDefinition field. The confusion might have sparked from the fact that both queries try to ensure encryption is enabled but the types of encryption are different and are not interchangeable. (At Rest Encryption / In Transit Encryption)

  • Both CloudFormation queries are , currently, missing the case for the lack of the EFSVolumeConfiguration field; this case is not missing in the original terraform query.

  • Given all this we have :

Proposed Changes

  • I started by simply adjusting all mentions of the 2 relevant fields (Volumes and EFSVolumeConfiguration) to the correct nomenclature.

  • Additionally i found the test folder to be lacking yaml test files, currently it has exclusively JSON files. I created tests similar to the ones already incorporated written in yaml format whilst also adjusting the field naming.

  • Some E2E tests have been updated since the AWS::ECS::TaskDefinition resource from e2e/fixtures/samples/positive.yaml is now flagging as it always should have, due to lack of the EFSVolumeConfiguration field.

  • Finally i adjusted the "searchKey" values to pinpoint results more accurately in the same way the "searchLine" was already doing and i implemented the missing case found on the terraform original query. (case of missing "EFSVolumeConfiguration" field)

  • I adjusted the terraform's query original name "ECS Task Definition Volume Not Encrypted" to "EFS Volume With Disabled Transit Encryption". This way it will be easy to recognize the 2 queries from each platform as equivalent in the future.

  • For the metadata of the queries there were changes made to better adjust various details to current implementation/context (cwe/documentation/severity).

  • An initial implementation of the "ECS Cluster Not Encrypted At Rest" was commited , but it was decided the query required further research before moving on with the implementation(fallback commit). That said this initial implementation should be included in a "dangling" PR for future reference. (Draft PR)

Note: all test files from the "ECS Cluster Not Encrypted At Rest" query have been checked to be flagged identically by the adjusted EFS Volume query. The 2 instances that did not get flagged are the case of the TaskDefinition field referencing a resource that does not exist; those , however, did get correctly flagged as "Empty Roles For ECS Cluster Task Definitions" , this seems like the correct flag for this scenario and since the query naming/description of "ECS Cluster Not Encrypted At Rest" was unrelated to the issue to begin with, it seems to be a True Negative for the EFS Volume query.

  • PS: After #7638 the case of "Volumes" missing entirely came to light with the QA process and was added to the implementation of "EFS Volume With Disabled Transit Encryption" accordingly along with new tests. With this the E2E tests (31/32/40) also had to be adjusted since they flag for both queries now.
    • Although my initial "ECS Cluster Not Encrypted At Rest" query proposal will not be implemented it was decided the recent changes done to it (#7563 and #7638) will be rolled back by this PR to lower amount of duplicate / False Positive Results given that the query will always flag unjustified no matter what. (will be rolled back to #7510)

I submit this contribution under the Apache-2.0 license.

@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner July 24, 2025 15:56
@github-actions github-actions bot added query New query feature cloudformation CloudFormation query aws PR related with AWS Cloud labels Jul 24, 2025
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
Copy link
Contributor

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the terraform Terraform query label Aug 1, 2025
@Checkmarx Checkmarx deleted a comment from gitguardian bot Aug 5, 2025
@Checkmarx Checkmarx deleted a comment from gitguardian bot Aug 5, 2025
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
…0736--FN_EFS_Volume_With_Disabled_Transit_Encryption--cloudformation/aws
@Checkmarx Checkmarx deleted a comment from gitguardian bot Aug 13, 2025
@Checkmarx Checkmarx deleted a comment from gitguardian bot Aug 14, 2025
@Checkmarx Checkmarx deleted a comment from gitguardian bot Aug 19, 2025
@Checkmarx Checkmarx deleted a comment from gitguardian bot Aug 25, 2025
@gitguardian
Copy link

gitguardian bot commented Aug 25, 2025

⚠️ GitGuardian has uncovered 3 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
19562607 Triggered Generic Password 74da8c2 assets/queries/common/passwords_and_secrets/test/positive53.json View secret
4266022 Triggered Generic Password 6e9f38e assets/queries/cloudFormation/aws/amplify_branch_basic_auth_config_password_exposed/test/negative7.yaml View secret
9419039 Triggered Username Password 6e9f38e assets/queries/cloudFormation/aws/amplify_branch_basic_auth_config_password_exposed/test/positive6.json View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Contributor

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
I don't know why we had a sample.yaml as a test file but nice revert from your side.

@cx-artur-ribeiro cx-artur-ribeiro merged commit cf1a5e6 into Checkmarx:master Aug 25, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws PR related with AWS Cloud cloudformation CloudFormation query query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

query(cloudformation): ecs cluster not encrypted at eest should be ecs task efs volume attachment not encrypted in transit

2 participants