Repository navigation
Conversation
…ell ACL The Gogo built-ins registered in the shell scope (cat, grep, head, tail, less, ls, sort, wc, cd and tac) open the files, directories and URLs given as arguments with the permissions of the Karaf process, and no shipped ACL rule covered them. Check each of these arguments, after Gogo has parsed the options, against a new .file rule in the shell ACL. When no rule matches, only admin has access, so an etc/ kept from an older version is covered too. Reading standard input isn't checked, so piping the output of a command into grep, less or wc keeps working for every user. shell:source, which reads its script from a file or URL, is restricted to admin.
Test Results 656 files - 476 656 suites - 476 36m 17s ⏱️ - 2h 50m 41s For more details on these failures, see this check. Results for commit c2d73c0. ± Comparison against base commit dcc0ea4. This pull request removes 2 and adds 14 tests. Note that renamed tests count towards both. |
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.
Problem
The Gogo built-ins registered in the
shellscope (cat,grep,head,tail,less,ls,sort,wc,cdandtac) open the files, directories and URLs given as arguments with the permissions of the Karaf process. The shippedorg.apache.karaf.command.acl.shellhas no rule for them, so they are open to any user who can log in to the console.shell:source, which reads its script from a file or URL, is open too.A rule on the command name wouldn't do: these built-ins are also used to filter or page the output of other commands (
bundle:list | grep foo,help | more), which every user needs.Fix
FileAccessGuardsubclasses Gogo'sPosixandBuiltin. It checks each file, directory or URL argument after Gogo has parsed the options, so options are never taken for files:grep's pattern isn't checked,lswith no argument checks the current directory, and-is standard input for the commands that read it.tac FILE, which writes its standard input toFILE, is checked too. The location is made absolute and normalized before the check.SessionFactoryImpl.checkFileAccess()is the hook.SecuredSessionFactoryImplchecks it against a new.filepseudo-command in the shell ACL, next to.invokeand.redirect, as the session's subject..filefails closed: when no rule matches it, onlyadminhas access. Anetc/kept from an older version, which has no.filerule, is covered too. A rule can open file access to other roles, for example.file = admin,viewer.grep,less,wc... keeps working for every user..file = adminandsource = admin: standardfeature.xml, child-instance template, itest fixture.security.adocdocuments both rules.Testing
FileAccessGuardTestruns the real built-ins in a headless session: denied files are neither read (cat,head,tail,wc,sort,less,grep) nor written (tac,tac -a); URLs are refused before they are opened;ls,cdand relative paths are resolved and normalized; standard input and commands without files aren't checked.SecuredSessionFactoryImplFileAccessTestcovers the ACL decision: no shell ACL, an ACL without a.filerule, the shipped rule, a role list and an argument rule.ShellCommandSecurityTest#testFileBuiltinsViaSsh: aviewergetsInsufficient credentialsforcat,grep,head,shell:ls, a URL andtac FILE(no file is created), andCommand not foundforshell:source; it can still pipe intogrepandwc;admincan still read and list files.shell.corebundle, with both the old and the new shell ACL.adminis unaffected, andhelp | moreandecho hello | lessstill page interactively for aviewer.mvn test -pl shell/core: 40 passedmvn test -Ptest -Dtest='org/apache/karaf/itests/ssh/*Test'initests/test: 16 passedmvn apache-rat:check -pl shell/core,itests/test,instance: passedThis touches the same ACL blocks as #3153, so whichever is merged second needs a trivial rebase.