Repository navigation
Description
User Story
I use OpenShell to run Snowflake's Cortex Code CLI (cortex) in a sandbox against one Snowflake account. I need the sandbox to hold no Snowflake credential, while the agent can still sign in to exactly that account. I first ran this on OpenShell 0.1.9 with a hand-written provider profile and have now measured a hardened version of it on 0.1.10 (below). This affects anyone who gives an agent access to a Snowflake account.
Problem Statement
providers/ has no example for a service whose API host is different for every customer and whose credential travels in the JSON body of a sign-in request, not in an Authorization header. A user has to work out four things unaided. I measured each on 0.1.10 with a mock upstream and dummy tokens:
- the host must be pinned to one account: a wildcard such as
*.snowflakecomputing.combinds the token to every name it matches (measured with*.openshell.internal); - body rewriting must cover only the sign-in request (
request_body_credential_rewriteon one path), and the rest of the host needs its own entry without it, because every endpoint of a profile that declares credentials is treated as credentialed; - a credential with no declared placement, or with
auth_style: bearer, is also substituted in theAuthorizationheader on every path of the host, so the token would go to every path and not only to the sign-in body; - rules on the sign-in endpoint do not make it POST-only by themselves: allow rules of overlapping endpoints add up, and with
access: fullon the second endpoint a request with an unusual method token (PROPFIND, LINK, ...) on a reused connection was admitted on the sign-in path with its body rewritten.
Impact / Why This Matters
Without a reviewed example, users put the token in the sandbox environment, where the agent can read it, or write a profile that sends it to every path or every account. The existing files (github.yaml, openrouter.yaml, oci-genai.yaml and others) cover header-borne credentials and inference endpoints; none uses request_body_credential_rewrite or a per-customer host. The per-deployment host problem was described in #2547.
Proposed Design
Add providers/snowflake.yaml, a reviewable example in the format of the existing files (the profile is below; its header comment states what was tested and the limits):
- one credential,
SNOWFLAKE_TOKEN(a Snowflake programmatic access token); the sandbox holds a placeholder. It declares a path placement,/openshell-unused/{credential}, that no client sends, and the second endpoint denies that path. The placeholder is then refused inAuthorization(Bearer, Basic, token), in other headers, in a query string and in other path segments. A declared header would not work: deny rules cannot match headers, and an unused header was substituted on every path; - endpoint 1: the account host, port 443, path
/session/v1/login-request,request_body_credential_rewrite: true, one allow rule for POST and deny rules for the six other standard methods; - endpoint 2: the same host, no rewrite, explicit allow rules for GET, HEAD, POST, PUT, PATCH, DELETE and OPTIONS on
/**instead ofaccess: full; binariesnaming the CLI paths, with a note on what that does and does not contain;- the account host written as
myorg-myaccount.snowflakecomputing.com, which the user replaces (it appears twice).
Notional use:
openshell profile import -f providers/snowflake.yaml
openshell provider create --name snowflake --type snowflake --from-existing # reads SNOWFLAKE_TOKEN
openshell sandbox create --provider snowflake -- cortexThe profile, without its header comment
id: snowflake
display_name: Snowflake
description: Snowflake account access with a token substituted at sign-in only
category: data
credentials:
- name: token
description: Snowflake programmatic access token
env_vars: [SNOWFLAKE_TOKEN]
required: true
auth_style: path
path_template: /openshell-unused/{credential}
discovery:
credentials: [token]
endpoints:
# Sign-in: the only request whose body may carry the token. POST only: the deny
# rules cover the other standard methods, and the second endpoint allows no
# other method.
- host: myorg-myaccount.snowflakecomputing.com
port: 443
path: /session/v1/login-request
protocol: rest
enforcement: enforce
rules:
- allow: { method: POST, path: /session/v1/login-request }
deny_rules:
- { method: GET, path: /session/v1/login-request }
- { method: HEAD, path: /session/v1/login-request }
- { method: PUT, path: /session/v1/login-request }
- { method: PATCH, path: /session/v1/login-request }
- { method: DELETE, path: /session/v1/login-request }
- { method: OPTIONS, path: /session/v1/login-request }
request_body_credential_rewrite: true
# Everything else on the account host: inspected, no substitution. The deny rule
# makes the unused placement above impossible to use.
- host: myorg-myaccount.snowflakecomputing.com
port: 443
protocol: rest
rules:
- allow: { method: GET, path: "/**" }
- allow: { method: HEAD, path: "/**" }
- allow: { method: POST, path: "/**" }
- allow: { method: PUT, path: "/**" }
- allow: { method: PATCH, path: "/**" }
- allow: { method: DELETE, path: "/**" }
- allow: { method: OPTIONS, path: "/**" }
enforcement: enforce
deny_rules:
- { method: "*", path: "/openshell-unused/**" }
binaries:
- /sandbox/coco-*/cortex
- /sandbox/.local/share/cortex/*/cortexAcceptance Criteria
-
openshell profile lint -f providers/snowflake.yamlpasses on the current release. - With the profile imported and a provider attached, a process in the sandbox sees only the placeholder for
SNOWFLAKE_TOKEN. - The token reaches the account host only in the body of the sign-in POST. A placeholder in
Authorization, another header, a query string or a path segment is refused or the connection is closed, and nothing is forwarded. - Other methods on the sign-in path are denied, including an unusual method token on the second request of a connection.
- A request to a different Snowflake account host is denied.
- The header comment names binaries, image layout, credential scope, endpoint access, limits and a smoke test, like the other files, and says what was not tested.
Alternatives Considered
- Keep the profile in the user's own repository. It works today, but it is not reviewed alongside the others, and each user rediscovers host pinning, one-path rewriting and placement.
- A documentation page instead of a file. Less testable:
profile lintcannot check it. - The
--hostoverride proposed in feat(providers): ship built-in Jira and MLflow provider profiles #2547 would let one generic profile serve every account. This example does not depend on it. - A companion policy: the profile holds only the sign-in endpoint and the user's policy grants the rest of the host, with
request_body_credential_rewrite: truealso set on that host-wide endpoint. Tested; it satisfies the agreement sentence in the docs literally (see the first question below). Not chosen because the profile is no longer self-contained. - Middleware or a gateway interceptor. Not needed: the provider and the proxy already do what is required.
Agent Investigation
Measured on OpenShell 0.1.10 with curl in a sandbox, a mock upstream over plain HTTP and dummy tokens: seven profile variants, a baseline suite of about 100 cases, and an independent attack pass of about 830 further cases. Against the final profile every upstream request that carried the token was a sign-in POST body (method names match without regard to case): none elsewhere in the baseline suite or in 617 attack cases run after the method fix. The first attack pass found that the earlier form of this profile, with access: full on the second endpoint, admitted PROPFIND on the sign-in path as the second request of a reused connection with the token substituted in its body; the explicit method rules above fix that. Read: providers/README.md, providers/github.yaml, the profile documentation, crates/openshell-policy/src/ambiguity.rs, l7/rest.rs, l7/path.rs.
Not tested: TLS (the proxy's upstream leg did not trust my test CA), Snowflake itself, the CLI, the programmatic-access-token sign-in shape and the CLI's install layout; the header says so. Related: #6068 (compressed request bodies and the body rewrite).
Questions for maintainers:
- The docs say inspected endpoints that can match one request must agree on credential settings.
ambiguity.rs(identical at v0.1.10 and main) compares only equally specific overlapping paths, so this pair, which differs inrequest_body_credential_rewrite, is accepted, as is the shape ofgithub.yaml. Which behavior is intended? If it is the docs sentence, the companion-policy form above is the fallback. - The proxy sniffs the method only on the first plain-HTTP request of a connection (nine names); later requests accept any method token, and
access: fulladmits them. Is that intended? - Would you prefer the example without the unused-placement device (it exists because deny rules cannot match headers)?
Checklist
- I've reviewed existing issues and the published docs
- This is a design proposal, not a "please build this" request
Activity