Bird
Raised Fist0
GCPcloud~20 mins

Security best practices in GCP - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Security Best Practices Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ security
intermediate
2:00remaining
Identify the least privilege principle in IAM roles

You have a Google Cloud project with multiple users. Which IAM role assignment best follows the least privilege principle?

AAssign the 'Viewer' role to users who only need to read resources.
BAssign the 'Owner' role to all users for full access.
CAssign the 'Editor' role to users who only need to deploy applications.
DAssign the 'Storage Admin' role to users who manage Compute Engine instances.
Attempts:
2 left
💡 Hint

Think about giving users only the permissions they need to do their job.

❓ Architecture
intermediate
2:00remaining
Choosing the best network security setup

You want to protect your Google Cloud VM instances from unauthorized internet access. Which setup provides the best security?

APlace VMs in a public subnet with firewall rules allowing all traffic.
BAssign external IPs to VMs and disable firewall rules.
CUse default network with no firewall rules.
DPlace VMs in a private subnet with no external IPs and use Cloud NAT for outbound internet access.
Attempts:
2 left
💡 Hint

Think about how to keep VMs unreachable from the internet but still allow them to access the internet if needed.

❓ Configuration
advanced
2:00remaining
Detecting misconfigured Cloud Storage bucket permissions

Which of the following Cloud Storage bucket IAM policies will publicly expose the bucket contents?

A{"bindings": [{"role": "roles/storage.admin", "members": ["group:admins@example.com"]}]}
B{"bindings": [{"role": "roles/storage.objectViewer", "members": ["user:alice@example.com"]}]}
C{"bindings": [{"role": "roles/storage.objectViewer", "members": ["allUsers"]}]}
D{"bindings": [{"role": "roles/storage.objectCreator", "members": ["serviceAccount:my-sa@project.iam.gserviceaccount.com"]}]}
Attempts:
2 left
💡 Hint

Look for the member that allows anyone on the internet access.

❓ service_behavior
advanced
2:00remaining
Understanding Cloud KMS key rotation impact

You rotate a Cloud KMS key used to encrypt data in Cloud Storage. What happens to the data encrypted with the old key version?

AData encrypted with old key versions remains accessible and can be decrypted.
BData encrypted with old key versions is deleted after key rotation.
CData encrypted with old key versions is automatically re-encrypted with the new key version.
DData encrypted with old key versions becomes unreadable immediately.
Attempts:
2 left
💡 Hint

Think about how key versions work in encryption.

🧠 Conceptual
expert
2:00remaining
Analyzing the effect of enabling VPC Service Controls

You enable VPC Service Controls around your Google Cloud project. Which of the following is a direct effect of this action?

AIt automatically encrypts all data at rest with customer-managed keys.
BIt prevents data exfiltration by restricting access to services from outside the defined perimeter.
CIt disables all firewall rules in the VPC network.
DIt allows unrestricted access to Cloud Storage buckets within the project.
Attempts:
2 left
💡 Hint

Consider what VPC Service Controls are designed to protect against.

Practice

(1/5)
1. Which of the following is a key security best practice when managing access to Google Cloud resources?
easy
A. Give all users owner permissions for convenience
B. Assign the least privilege necessary using IAM roles
C. Share your service account keys publicly
D. Disable all logging to improve performance

Solution

  1. Step 1: Understand IAM role assignment

    IAM roles control what users can do. Assigning least privilege means giving only the permissions needed.
  2. Step 2: Evaluate options for security

    Giving owner permissions broadly or sharing keys publicly risks unauthorized access. Disabling logging hides important audit info.
  3. Final Answer:

    Assign the least privilege necessary using IAM roles -> Option B
  4. Quick Check:

    Least privilege = Assign minimal permissions [OK]
Hint: Always give only needed permissions, never more [OK]
Common Mistakes:
  • Giving broad permissions for convenience
  • Sharing keys or credentials publicly
  • Disabling audit logs
2. Which of the following is the correct way to encrypt data in Google Cloud using Cloud KMS?
easy
A. Use Cloud KMS to generate encryption keys and encrypt data with those keys
B. Store encryption keys in plaintext in Cloud Storage
C. Encrypt data manually without using Cloud KMS
D. Disable encryption to improve speed

Solution

  1. Step 1: Understand Cloud KMS role

    Cloud KMS manages encryption keys securely and helps encrypt/decrypt data safely.
  2. Step 2: Evaluate encryption methods

    Storing keys in plaintext or disabling encryption risks data exposure. Manual encryption is error-prone.
  3. Final Answer:

    Use Cloud KMS to generate encryption keys and encrypt data with those keys -> Option A
  4. Quick Check:

    Cloud KMS = Secure key management [OK]
Hint: Always use Cloud KMS for key management and encryption [OK]
Common Mistakes:
  • Storing keys unencrypted
  • Skipping encryption for speed
  • Encrypting data without key management
3. Consider this IAM policy snippet in JSON format:
{
  "bindings": [
    {
      "role": "roles/storage.objectViewer",
      "members": ["user:alice@example.com"]
    }
  ]
}

What permission does Alice have on the storage bucket?
medium
A. She can upload and delete objects
B. She has no access
C. She can only view objects
D. She can manage bucket settings

Solution

  1. Step 1: Identify the role assigned

    The role is roles/storage.objectViewer, which grants read-only access to objects.
  2. Step 2: Understand permissions of the role

    This role allows viewing objects but not uploading, deleting, or managing bucket settings.
  3. Final Answer:

    She can only view objects -> Option C
  4. Quick Check:

    objectViewer = read-only access [OK]
Hint: Viewer roles allow read-only access, no changes [OK]
Common Mistakes:
  • Confusing viewer with editor or owner roles
  • Assuming upload/delete permissions
  • Ignoring role details
4. You have a service account key stored in a public GitHub repository. What is the best immediate action to secure your Google Cloud environment?
medium
A. Change the project name to confuse attackers
B. Ignore it since the key is not used
C. Share the key with your team for transparency
D. Delete the exposed key and create a new one

Solution

  1. Step 1: Recognize the risk of exposed keys

    Publicly exposed keys can be used by attackers to access resources.
  2. Step 2: Take immediate action to revoke and replace keys

    Deleting the exposed key and creating a new one prevents unauthorized access.
  3. Final Answer:

    Delete the exposed key and create a new one -> Option D
  4. Quick Check:

    Exposed keys = revoke immediately [OK]
Hint: Revoke exposed keys immediately to prevent breaches [OK]
Common Mistakes:
  • Ignoring exposed keys
  • Changing unrelated settings
  • Sharing keys openly
5. You want to enforce that all data stored in Cloud Storage buckets is encrypted with customer-managed keys (CMKs) using Cloud KMS. Which combination of steps ensures this security best practice?
hard
A. Create a Cloud KMS key ring and key, then configure the bucket to use this key for default encryption
B. Store keys in a Compute Engine instance and manually encrypt files before upload
C. Use Google-managed encryption only and disable Cloud KMS
D. Encrypt files locally and upload without bucket encryption settings

Solution

  1. Step 1: Create a Cloud KMS key ring and key

    This provides a customer-managed key to control encryption.
  2. Step 2: Configure the Cloud Storage bucket to use the CMK for default encryption

    This ensures all objects are encrypted automatically with your key.
  3. Final Answer:

    Create a Cloud KMS key ring and key, then configure the bucket to use this key for default encryption -> Option A
  4. Quick Check:

    CMK + bucket default encryption = secure data [OK]
Hint: Use CMK with bucket default encryption for strong control [OK]
Common Mistakes:
  • Relying only on Google-managed keys
  • Encrypting manually without bucket settings
  • Storing keys insecurely
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard