Thoughts on arbitrary scripts

Hey,
Just wanna share something I was thinking about today.

We do have one well known instance of a use case that requires that the user passes an arbitrary script that will be run in a worker, which is the signing servcies. And because we know that’s very dangerous, we gate-keep it as an admin-only operation, not available at all via API.

But I feel like there are some desire for passing scripts in some places. For instance, we just learned that pulp_workflow allows that via API, and we’ve heard people wanting to have custom “linting” of packages, or things like that.

What if we allow passing a signing script via API (for singing, for example), but then require that it’s signed by the admin? The admin register it’s public key via a management command in Pulp, and it’s used to verify that a script got the blessing of the admin. I guess that reduces the attack surface, while removing the incovenience of having to ssh into the system. Of course, it introduces another point of friction, which is that there must be some manual interaction to approve the script, but that’s the trade-off security, right? The difference, as far as I understand, is that it is particularly impractical to execute these manual system interventions in an environments like k8s.

Anyway, just some thoughts.

We could also go the other way around and just get rid of custom scripts!
Implement something like a remote service protocol, a service definition that the worker can use to talk to, exchange files, messages, etc. And then people just have to implement their services behind this API contract.

1 Like

I think this isn’t a bad approach, if we want to allow this. The window we open with this, is any script run by the worker runs with all the permissions Pulp has, and has access to Pulp’s execution environment. At a minimum, it could (even accidentally) take Pulp itself down, or peg the machine it’s running on in an inadvertent DDoS. More distressingly, it can also lead to things like exfiltrating secrets held in environment variables, blowing away Pulp’s db, or allowing an attacker ingress to the system as a toehold into the install’s network. If the pulp-instance is “well and correctly set up”, permissions and network rules and selinux work to contain some of this - but that’s out of our control.

I’m not averse to exploring the concept of a “trusted script API”. But it has to come with considerations like “what happens when the admin-key is rotated? How do we revoke access to any/every script signed with key X? Do we re-verify on every execution of the script? If the script has to be signed by the admin - is that actually any easier than the admin just doing the work directly?”

I know there’s a real desire for this, because the current path is Inconvenient. But it’s inconvenient for a very good reason.

1 Like

I think you could require the “being singed with the current admin key” only at entering the system. That would account for the key rotation.

On the other side introducing apis to offload signing would need some serious key setup anyway and it feels like just kicking the can down the road at the expense of creating a whole new front on the attack surface…

I am admin, I have a key, X. It gets compromised. You can now use X, to sign your script, and submit it. It’s correctly signed and is accepted. Now, I find out X was compromised. I need to be able to tell pulp “do not trust anything signed with X”, while I am finding any/all scripts signed with X, evaluating them, re-signing any good ones with Y, and deleting the ones I don’t trust. It’s this kind of edge-case we need to make sure we support.

2 Likes

So we make it a keyring. Now you can smoothly roll keys over.

1 Like

OTOH, you can inject the whole signing script as a secret into the running container (/var/run/secret/…). So we can also rely on the gap being bridged somewhere else?

The thing about an API service is that, even though one can inject a malicous API server/service, that service doesn’t have the level of access to the system that a script does, as an API-based have a narrow “vocabulary” to talk to the system. That’s it, the script has more ways to try to break the system.

But on the other hand, if it’s exposed via the API, so we increase the attack surface there as we already discussed, and we introduce the surface attack of the service side, because it can be compromised independently (maybe that’s what you meant with “kicking the can down the road”).

If the script has to be signed by the admin - is that actually any easier than the admin just doing the work directly?”

This is an important question to ask. It’s a tradeoff: the idea of signing makes it easier for the operator/admin, because now it just needs to review and sign a thing, it doesn’t need to touch the system. For the user it doesnt make much of a difference, it has to ask the admin either way, and just call an extra API endpoint to create it (instead of relying on the admin to run the create management commands).

Now, I’ve heard about this friction of running this management commands, but if it’s really not a big deal, then well… maybe it’s not a big deal to keep with the management command model.

1 Like

FWIW, motivated by our pulpcon 2026 discussions, pulp_workflow is going in the direction of being “compliant” with the signing-service management command approach!

1 Like

Yet another option that I haven’t heard anyone dare to speak out loud seriously: move trusting from deployment to develpoment. We just bite the bullet of the “but there are too many services integrations” and include scripts with clear APIs, some that can be in core and/or extended via pulp’s plugins (non-content plugins!). From a maintenance perspective, that doesn’t sound too different from other integrations, like our storage integrations that need to support a set of external services (specially now with django-storages vendored) in the sense that we’d need to know about specific service APIs.

For popular services, I would expect this to greatly reduce fiction. For non-popular/highly tailored services, this would increase friction. And again a tradeoff, now instead of asking the admin for a singing service, you will open a feature request, or bake your own on a plugin (if we developers don’t wanna accept a given service, one could write a pulp plugin with the sole purpose of register/creates some tailored services.).

The benefit is community reusability: as a user, if the service you need exist, you are simply good to go; it’s not less trustworthy than any other component of pulp; if it doesn’t exist, the first user will pay the price of submitting a PR/issue, but others would benefit in the future.

A underlying assumption here is that, even though services can vary, there is a way to scope them (as signing-services are scoped at taking a blob and spitting a signature, or a modified blob) and still accomodate specifics of service variants (e.g, remote signing, leveraging crypto-hardware, etc).

* Note I’m saying service and not singing-service, because I’m thinking this in a general way. For instance, pulp_workflow gave an example of adding something like a notification/webook service. What I’m also trying to plan/discuss here is this long term perspective of the general idea of services attached to specific hooks, and which have a well defined goal and contract.