Skip to content

Commit d12b805

Browse files
authored
[cloud] Provide ability to disable executing modified pxl scripts (#2062)
Summary: [cloud] Provide ability to disable executing modified pxl scripts Certain security conscious users are hesitant to use Pixie because without RBAC anyone with Pixie UI access can write arbitrary BPF code (bpftrace integration), access or export arbitrary data (modifying pxl scripts, writing export scripts). This change aims to address this concern with a global setting to prevent the ability to execute modified scripts. When an adhoc script is executed, the cloud will hash the contents of the script and check it against the scripts known to the scriptmgr service. If it is contained in the scriptmgr service, the script will be allowed to execute. Note: this does not prevent users from writing new export scripts. Since the query broker can source its scripts from a configmap as of #1326, this is deemed as an appropriate mitigation for cluster admins and I'll follow up with UI support to reflect that a vizier is in "configmap mode". Relevant Issues: N/A Type of change: /kind feature Test Plan: The following checks were performed - [x] New tests verify the scriptmgr and api service changes work - [x] Skaffold'ed to a testing cluster and verified script modification is blocked and unmodified scripts are allowed to run. In addition to this, the code editor in the UI is made read only and shows an explanation <details><summary>Screenshots</summary> ![Screen Shot 2025-01-07 at 8 58 34 AM](https://github.com/user-attachments/assets/26c7cc23-08e2-4064-ab15-6172a2593391) ![Screen Shot 2025-01-07 at 8 58 37 AM](https://github.com/user-attachments/assets/8ddf05be-7f83-4935-af0a-44b424a8dc8a) ![Screen Shot 2025-01-07 at 8 58 59 AM](https://github.com/user-attachments/assets/b0033854-758d-4843-98ca-39120f8f8326) </details> Changelog Message: Pixie Cloud can now disable executing modified pxl scripts via the `PL_SCRIPT_MODIFICATION_DISABLED` key in the `pl-script-bundle-config` ConfigMap. See reference manifests for more details. --------- Signed-off-by: Dom Del Nano <[email protected]>
1 parent f1b52d3 commit d12b805

23 files changed

+886
-68
lines changed

k8s/cloud/base/api_deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
name: pl-ory-service-config
4141
- configMapRef:
4242
name: pl-auth-connector-config
43+
- configMapRef:
44+
name: pl-script-bundles-config
4345
- configMapRef:
4446
name: pl-errors-config
4547
optional: true
@@ -59,6 +61,11 @@ spec:
5961
configMapKeyRef:
6062
name: pl-service-config
6163
key: PL_VZMGR_SERVICE
64+
- name: PL_SCRIPTMGR_SERVICE
65+
valueFrom:
66+
configMapKeyRef:
67+
name: pl-service-config
68+
key: PL_SCRIPTMGR_SERVICE
6269
- name: PL_AUTH_SERVICE
6370
valueFrom:
6471
configMapKeyRef:

k8s/cloud/base/proxy_nginx_config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ data:
3535
sub_filter '__CONFIG_DOMAIN_NAME__' "'${domain_name}'";
3636
sub_filter '__CONFIG_SCRIPT_BUNDLE_URLS__' "'${script_bundle_urls}'";
3737
sub_filter '__CONFIG_SCRIPT_BUNDLE_DEV__' "'${script_bundle_dev}'";
38+
sub_filter '__CONFIG_SCRIPT_MODIFICATION_DISABLED__' "${script_modification_disabled}";
3839
sub_filter '__SEGMENT_UI_WRITE_KEY__' "'${segment_ui_write_key}'";
3940
sub_filter '__SEGMENT_ANALYTICS_JS_DOMAIN__' "'segment.${domain_name}'";
4041
sub_filter '__CONFIG_LD_CLIENT_ID__' "'${ld_client_id}'";
@@ -134,6 +135,7 @@ data:
134135
set_by_lua_block $segment_cli_write_key { return os.getenv("PL_SEGMENT_CLI_WRITE_KEY") }
135136
set_by_lua_block $script_bundle_urls { return os.getenv("SCRIPT_BUNDLE_URLS") }
136137
set_by_lua_block $script_bundle_dev { return os.getenv("SCRIPT_BUNDLE_DEV") }
138+
set_by_lua_block $script_modification_disabled { return os.getenv("PL_SCRIPT_MODIFICATION_DISABLED") }
137139
set_by_lua_block $analytics_enabled { return os.getenv("ANALYTICS_ENABLED") }
138140
set_by_lua_block $announcement_enabled { return os.getenv("ANNOUNCEMENT_ENABLED") }
139141
set_by_lua_block $announce_widget_url { return os.getenv("ANNOUNCE_WIDGET_URL") }
@@ -169,7 +171,8 @@ data:
169171
env PL_HYDRA_SERVICE;
170172
env PL_KRATOS_SERVICE;
171173
env SCRIPT_BUNDLE_URLS;
172-
env SCRIPT_BUNDE_DEV;
174+
env SCRIPT_BUNDLE_DEV;
175+
env PL_SCRIPT_MODIFICATION_DISABLED;
173176
env ANALYTICS_ENABLED;
174177
env ANNOUNCEMENT_ENABLED;
175178
env ANNOUNCE_WIDGET_URL;

k8s/cloud/base/script_bundles_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ data:
99
"https://artifacts.px.dev/pxl_scripts/bundle.json"
1010
]
1111
SCRIPT_BUNDLE_DEV: "false"
12+
PL_SCRIPT_MODIFICATION_DISABLED: "false"

k8s/cloud/dev/script_bundles_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ data:
1010
"https://artifacts.px.dev/pxl_scripts/bundle.json"
1111
]
1212
SCRIPT_BUNDLE_DEV: "false"
13+
PL_SCRIPT_MODIFICATION_DISABLED: "false"

k8s/cloud/prod/script_bundles_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ data:
1010
"https://artifacts.px.dev/pxl_scripts/bundle.json"
1111
]
1212
SCRIPT_BUNDLE_DEV: "false"
13+
PL_SCRIPT_MODIFICATION_DISABLED: "false"

k8s/cloud/public/base/script_bundles_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ data:
99
"https://artifacts.px.dev/pxl_scripts/bundle.json"
1010
]
1111
SCRIPT_BUNDLE_DEV: "false"
12+
PL_SCRIPT_MODIFICATION_DISABLED: "false"

k8s/cloud/staging/script_bundles_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ data:
1010
"https://artifacts.px.dev/pxl_scripts/bundle.json"
1111
]
1212
SCRIPT_BUNDLE_DEV: "false"
13+
PL_SCRIPT_MODIFICATION_DISABLED: "false"

k8s/cloud/testing/script_bundles_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ data:
1010
"https://artifacts.px.dev/pxl_scripts/bundle.json"
1111
]
1212
SCRIPT_BUNDLE_DEV: "false"
13+
PL_SCRIPT_MODIFICATION_DISABLED: "false"

src/cloud/api/api_server.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func init() {
6666

6767
pflag.String("auth_connector_name", "", "If any, the name of the auth connector to be used with Pixie")
6868
pflag.String("auth_connector_callback_url", "", "If any, the callback URL for the auth connector")
69+
pflag.Bool("script_modification_disabled", false, "If script modification should be disallowed to prevent arbitrary script execution")
6970
}
7071

7172
func main() {
@@ -213,17 +214,18 @@ func main() {
213214
authServer := &controllers.AuthServer{AuthClient: ac}
214215
cloudpb.RegisterAuthServiceServer(s.GRPCServer(), authServer)
215216

216-
vpt := ptproxy.NewVizierPassThroughProxy(nc, vc)
217-
vizierpb.RegisterVizierServiceServer(s.GRPCServer(), vpt)
218-
vizierpb.RegisterVizierDebugServiceServer(s.GRPCServer(), vpt)
219-
220217
sm, err := apienv.NewScriptMgrServiceClient()
221218
if err != nil {
222219
log.WithError(err).Fatal("Failed to init scriptmgr client.")
223220
}
224221
sms := &controllers.ScriptMgrServer{ScriptMgr: sm}
225222
cloudpb.RegisterScriptMgrServer(s.GRPCServer(), sms)
226223

224+
scriptModificationDisabled := viper.GetBool("script_modification_disabled")
225+
vpt := ptproxy.NewVizierPassThroughProxy(nc, vc, sm, scriptModificationDisabled)
226+
vizierpb.RegisterVizierServiceServer(s.GRPCServer(), vpt)
227+
vizierpb.RegisterVizierDebugServiceServer(s.GRPCServer(), vpt)
228+
227229
mdIndexName := viper.GetString("md_index_name")
228230
if mdIndexName == "" {
229231
log.Fatal("Must specify a name for the elastic index.")

src/cloud/api/apienv/scriptmgr_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
)
2929

3030
func init() {
31-
pflag.String("scriptmgr_service", "scriptmgr-service.plc.svc.local:52000", "The profile service url (load balancer/list is ok)")
31+
pflag.String("scriptmgr_service", "scriptmgr-service.plc.svc.local:52000", "The scriptmgr service url (load balancer/list is ok)")
3232
}
3333

3434
// NewScriptMgrServiceClient creates a new scriptmgr RPC client stub.
@@ -38,7 +38,7 @@ func NewScriptMgrServiceClient() (scriptmgrpb.ScriptMgrServiceClient, error) {
3838
return nil, err
3939
}
4040

41-
authChannel, err := grpc.Dial(viper.GetString("scripts_service"), dialOpts...)
41+
authChannel, err := grpc.Dial(viper.GetString("scriptmgr_service"), dialOpts...)
4242
if err != nil {
4343
return nil, err
4444
}

0 commit comments

Comments
 (0)