Repository navigation
Conversation
SANDBOX_SECRETS and SANDBOX_SECRET_<NAME> only reached OpenShell. In the fakechroot and namespace jails secret() raised "no sandbox secrets are available", and a project's custom code reads the smss only for its owners, so an app had no way to give its Python a credential for the people who use it. When a jail loads a project, JailSecrets writes its declared secrets to <user chroot>/<BaseFolder>/sandbox-secrets/secrets.json, by project key, owner-only. fakechroot sees it at <BaseFolder>/sandbox-secrets inside the chroot; the namespace jail mounts the folder there read-only. secret() reads that file first and OpenShell's placeholders after, so app code and the .smss are the same in every mode. The jails hand over the value itself: the hosts are checked for form, not enforced. A read-only inject in the namespace launcher left the interpreter's copy writable: the mount propagated at the bind, and the read-only remount after it does not propagate. inject now binds a private read-only mount instead, and the self-test checks that a read-only grant refuses writes.
secret() read the jail's secrets.json first and fell back to OpenShell's placeholders.json when it was missing. A user whose jail had loaded no app with secrets has no secrets.json, so secret() read placeholders.json from the shared insight cache, which other users can write to. SEMOSS now makes the user's sandbox-secrets folder when it sets up a fakechroot or namespace jail, before any project is loaded, and the namespace jail mounts it read-only then. secret() takes the folder as the sign that it runs in a jail and reads only secrets.json there; outside a jail it reads the OpenShell file as before. The docs also say that the file permissions do not keep users apart in fakechroot: every user's Python runs as the same host user, and fakechroot only rewrites paths.
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A project's
SANDBOX_SECRETS/SANDBOX_SECRET_<NAME>only reached OpenShell. In the fakechroot and namespace jails,secret()raised "no sandbox secrets are available", and a project's custom code reads the.smssonly for its owners. So an app had no way to give its Python a credential for the people who use it.With this PR, the same
.smssand the samesecret()call work in every sandbox mode. In the jails the code gets the value itself, not a placeholder. Those jails have nothing in the request path that could swap a placeholder for the value, so the declared hosts are checked for form, so the project moves to OpenShell unchanged, but they are not enforced. The docs say so.It also fixes a read-only mount bug in the namespace launcher that affects every live read-only inject, viewer copies of projects included.
Changes Made
JailSecrets(src/prerna/util/sandbox/JailSecrets.java): when a jail loads a project, it writes the project's declared secrets to<user chroot>/<BaseFolder>/sandbox-secrets/secrets.json, keyed by project. The folder is0700and the file0600. The file is written to a temp file and renamed into place, so code reading it never sees half a file. It reusesOpenShellSecrets' parser and project keys, which are nowpublic.SymlinkHelper:<BaseFolder>/sandbox-secretspy/smss_secrets.py: when the secrets folder is present, the code is in a jail and reads onlysecrets.json. It never falls back to OpenShell'splaceholders.json, which is in the shared insight cache that other users can write to. Outside a jail it reads the OpenShell file as before.sandbox_launcher.inject(..., "ro"): remounting the destination read-only after the bind does not reach the interpreter's copy of the mount, so it stayed writable.injectnow makes a private read-only staging bind first and binds that into the jail. The self-test checks that a write from inside a read-only grant fails withEROFS.executor_sandbox.md(jail section) andsandbox_configuration.md. They say plainly that file permissions do not keep users apart in fakechroot: every user's Python runs as the same host user, and fakechroot only rewrites paths.How to Test
cd py && python3 -m unittest testing.test_smss_secrets. Expected: 6 tests OK. They include a test that a jail with nosecrets.jsonrefuses rather than reading a plantedplaceholders.json.python3 py/sandbox_launcher.py --self-test. Expected:ALL PASS (14/14), including "interpreter cannot write to read-only projectD (EROFS)".mvn test -Dtest='JailSecretsUnitTests,SymlinkHelperUnitTests'.nobodyCanWriteToAViewersCopyfails when run as root, because root ignores file permissions. It fails the same way ondev.SANDBOX_SECRETSwith a value in a project's.smss, load it in a fakechroot or namespace worker, then callsecret("<NAME>")from Python. Expected: the value. A user whose jail has loaded no project with secrets gets the "no sandbox secrets are available"KeyError.Notes
fix-namespace-shared-mounts: it keepspy/and the insight cache out of namespace jails but does not changeinject(). The read-only inject fix here is what makes viewer copies read-only, so the two should land together.sandbox-customizationrewrites the same branch ofinject(). That branch's own self-test fails "read-only project cannot be written" with and without--require-ro, so whichever merges second should keep the staging approach from this PR when resolving the conflict.