Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Case: POC Serverless Canary Application (frontend/backend/persistence) as a Profile 3 LZ workload with PSC, PSA and VPC-SC #418

Open
fmichaelobrien opened this issue Jul 6, 2023 · 4 comments
Assignees
Labels
canary Networking Solution Add or update a solution

Comments

@fmichaelobrien
Copy link
Contributor

fmichaelobrien commented Jul 6, 2023

202401 update

Use Cases

Serverless Reference Architecture

251522916-5603ef02-e51e-47b6-a203-e2df4ecab0fd

Requirements: LZ workload Canary for Profile 3

Design

Reference

Implementation

Package Coverage Required

Package Coverage Optional

Design Issues

  • watch CR Cloud Run service fails to apply update k8s-config-connector#832
  • lightweight JS frontend - minimal jquery/ajax - either encapsulated in container 1 or separate cloud functions knative app
  • container 1 : backend spring boot REST api (may contain javascript frontend as well)
  • container 2: backend Relational or key/value DB - may use Cloud SQL or Spanner

Template
Introduction
Deliverables
MVP - Immediate Minimum Viable Product
Quickstart
Artifacts
Requirements
Features
Analysis
API
Architecture
Use Cases
Design
Design Issues
DevOps
Deployment
Testing
Security
Monitoring
Releases
Documentation
Development Log
Keywords
References
Links

reference as well https://github.com/ssc-spc-ccoe-cei/gcp-tier34-template

@fmichaelobrien fmichaelobrien added Solution Add or update a solution canary labels Jul 6, 2023
@fmichaelobrien fmichaelobrien self-assigned this Jul 6, 2023
@obriensystems
Copy link
Collaborator

obriensystems commented Jul 6, 2023

@fmichaelobrien
Copy link
Contributor Author

fmichaelobrien commented Aug 22, 2023

Verify VPC-SC across 2 service projects in a shared VPC

Goal/Requirements

  • prevent exfiltration of data from a cloud storage bucket or bigquery instance in two of the service projects hosting both of these services

Testing

VPC Service control zone must include both service projects
Inventory

  • canary-host host project
  • canary-source-svc project
  • canary-target-svc project
  • vm-docker-source
  • vm-docker-target
Screenshot 2023-08-22 at 8 32 08 AM
  • enable compute api on all 3 projects
    In setup shared VPC - enable host on canary-host-ol -but first make a custom VPC and delete the default VPC
gcloud compute networks create dev --project=canary-host-ol --subnet-mode=custom --mtu=1460 --bgp-routing-mode=regional && gcloud compute networks subnets create dev-sn --project=canary-host-ol --range=10.10.0.0/24 --stack-type=IPV4_ONLY --network=dev --region=northamerica-northeast1 --enable-private-ip-google-access && gcloud compute firewall-rules create dev-allow-custom --project=canary-host-ol --network=projects/canary-host-ol/global/networks/dev --description=Allows\ connection\ from\ any\ source\ to\ any\ instance\ on\ the\ network\ using\ custom\ protocols. --direction=INGRESS --priority=65534 --source-ranges=10.10.0.0/24 --action=ALLOW --rules=all && gcloud compute firewall-rules create dev-allow-icmp --project=canary-host-ol --network=projects/canary-host-ol/global/networks/dev --description=Allows\ ICMP\ connections\ from\ any\ source\ to\ any\ instance\ on\ the\ network. --direction=INGRESS --priority=65534 --source-ranges=0.0.0.0/0 --action=ALLOW --rules=icmp && gcloud compute firewall-rules create dev-allow-rdp --project=canary-host-ol --network=projects/canary-host-ol/global/networks/dev --description=Allows\ RDP\ connections\ from\ any\ source\ to\ any\ instance\ on\ the\ network\ using\ port\ 3389. --direction=INGRESS --priority=65534 --source-ranges=0.0.0.0/0 --action=ALLOW --rules=tcp:3389 && gcloud compute firewall-rules create dev-allow-ssh --project=canary-host-ol --network=projects/canary-host-ol/global/networks/dev --description=Allows\ TCP\ connections\ from\ any\ source\ to\ any\ instance\ on\ the\ network\ using\ port\ 22. --direction=INGRESS --priority=65534 --source-ranges=0.0.0.0/0 --action=ALLOW --rules=tcp:22

share 2 svc projects
Screenshot 2023-08-22 at 8 47 05 AM

create vpc service control access policy at the org level

Screenshot 2023-08-22 at 8 51 17 AM Screenshot 2023-08-22 at 8 51 58 AM Screenshot 2023-08-22 at 8 52 24 AM

grant uses to the shared subnets

Screenshot 2023-08-22 at 9 40 50 AM

add projects to the perimeter

add resources to the perimeter to protect

Create VMs in subnets

gcloud compute instances create source-svc --project=canary-source-svc-ol --zone=northamerica-northeast1-a --machine-type=e2-small --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=projects/canary-host-ol/regions/northamerica-northeast1/subnetworks/dev-sn --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=531569623787-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name=source-svc,image=projects/debian-cloud/global/images/debian-11-bullseye-v20230814,mode=rw,size=10,type=projects/canary-source-svc-ol/zones/us-central1-a/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any

gcloud compute instances create ext-svc --project=canary-ext-svc-ol --zone=northamerica-northeast1-a --machine-type=e2-small --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=projects/canary-ext-host-ol/regions/northamerica-northeast1/subnetworks/dev-sn --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=910458337292-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/cloud-platform --create-disk=auto-delete=yes,boot=yes,device-name=ext-svc,image=projects/debian-cloud/global/images/debian-11-bullseye-v20230814,mode=rw,size=10,type=projects/canary-ext-svc-ol/zones/us-central1-a/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any

create a bucket with files to be accessed both inside and outside the perimeter in the source-svc project
Screenshot 2023-08-22 at 9 47 37 AM

Test access from ext-svc before/after perimeter is set

@fmichaelobrien fmichaelobrien changed the title Use Case: POC Serverless Canary Application (frontend/backend/persistence) as a Profile 3 LZ workload Use Case: POC Serverless Canary Application (frontend/backend/persistence) as a Profile 3 LZ workload with PSC, PSA and VPC-SC Aug 22, 2023
@obriensystems
Copy link
Collaborator

obriensystems commented Aug 22, 2023

check VM access to bucket inside future perimeter

michael@source-svc:~$ gsutil ls gs://canary-source-svc-ol/
gs://canary-source-svc-ol/Easter Brunch Global Tables Takehome Notes 2023 Letter.pdf

michael@ext-svc:~$ gsutil ls
michael@ext-svc:~$ 
michael@ext-svc:~$ gsutil ls gs://canary-source-svc-ol/
AccessDeniedException: 403 910458337292-compute@developer.gserviceaccount.com does not have storage.objects.list access to the Google Cloud Storage bucket. Permission 'storage.objects.list' denied on resource (or it may not exist).

add the VM service account as reader
Screenshot 2023-08-22 at 10 00 09

visible

michael@ext-svc:~$ gsutil ls gs://canary-source-svc-ol/
gs://canary-source-svc-ol/Easter Brunch Global Tables Takehome Notes 2023 Letter.pdf

set VPC service perimeter around the bucket specific to the source service project

add 2 projects to the perimeter
Screenshot 2023-08-22 at 10 02 27

add cloud storage to the perimeter
Screenshot 2023-08-22 at 10 03 10

checking - the reverse of what I expected - source is blocked, ext is not

michael@source-svc:~$ gsutil ls gs://canary-source-svc-ol/
gs://canary-source-svc-ol/Easter Brunch Global Tables Takehome Notes 2023 Letter.pdf

set projects in VPC-SC
michael@source-svc:~$ gsutil ls gs://canary-source-svc-ol/
AccessDeniedException: 403 Request is prohibited by organization's policy. vpcServiceControlsUniqueIdentifier: su8wcnumiqi2Urdl9NTTaymJAk_9AsbDaQef3wG8-wn_9zZwBuCSeQ

michael@ext-svc:~$ gsutil ls gs://canary-source-svc-ol/
gs://canary-source-svc-ol/Easter Brunch Global Tables Takehome Notes 2023 Letter.pdf

however turning on ext on and off in the perimeter sets the VPC SC flag - but I cannot get it reset

michael@ext-svc:~$ gsutil ls gs://canary-source-svc-ol/
AccessDeniedException: 403 Request is prohibited by organization's policy. vpcServiceControlsUniqueIdentifier: bPOAHVzoAq-3TnXxWL2yUnkOa8oLN9ub1sCEvKKqhbydgmzhWuYBV
Screenshot 2023-08-22 at 10 11 36

test reduction only to target
Screenshot 2023-08-22 at 10 10 50

delete perimeter but keep default policy - to reset
Screenshot 2023-08-22 at 10 14 03

recreate perimeter
Screenshot 2023-08-22 at 10 15 09

michael@source-svc:~$ gsutil ls gs://canary-source-svc-ol/
AccessDeniedException: 403 Request is prohibited by organization's policy. vpcServiceControlsUniqueIdentifier: i7PWPHxZaJjhRx5b_zD6ZoCZQ1TVRU8CC2-CwQU77xBceJ77wse7XA

michael@ext-svc:~$ gsutil ls gs://canary-source-svc-ol/
gs://canary-source-svc-ol/Easter Brunch Global Tables Takehome Notes 2023 Letter.pdf

VPC-SC: There are additional ingress and VPC owning project inclusion attributes to VPC Service Control - Perimeters in the policy such as per vpc/perimeter. Triaging VPC-SC config using a gs bucket in the notes starting at #418 (comment)

reference
https://cloud.google.com/vpc-service-controls/docs/overview#isolate

Missing the ingress rule and we also need the perimeter all the way around the host project as well - or else we use bridges

Screenshot 2023-08-22 at 13 39 13

after the ingress rule we have the proper internal gsutil usage and blocked external gsutil usage

michael@ext-svc:~$ gsutil ls gs://canary-source-svc-ol/
AccessDeniedException: 403 Request is prohibited by organization's policy. vpcServiceControlsUniqueIdentifier: 5hL_K1kXZRP8W1icoLReQSeY3DlkWplevoH5Ga6YwvESsEC_OVdXBA

michael@source-svc:~$ gsutil ls gs://canary-source-svc-ol/
gs://canary-source-svc-ol/Easter Brunch Global Tables Takehome Notes 2023 Letter.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
canary Networking Solution Add or update a solution
Projects
None yet
Development

No branches or pull requests

2 participants