Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0.0-alpha.4 #42

Merged
merged 44 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
883105d
first commit for json impl
LeChatP Mar 29, 2024
30ef903
first iteration for chsr (not working)
LeChatP Mar 29, 2024
4d939dd
remove legacy
LeChatP Apr 9, 2024
1a5a24a
It compiles
LeChatP Apr 14, 2024
17c30d5
fix help message
LeChatP Apr 14, 2024
025e7b9
Impl ok, need tests
LeChatP Apr 19, 2024
6466343
Refactor CLI parsing and add unit tests
LeChatP Apr 20, 2024
8fa7e17
some mistakes, thanks to tests that highlighted them
LeChatP Apr 20, 2024
9f55819
Refactor code to improve task matching and settings handling
LeChatP Apr 20, 2024
dd95dd9
chore: Simplify plugin subscription methods to remove position parameter
LeChatP Apr 20, 2024
f345694
chore: Register hierarchy plugin
LeChatP Apr 21, 2024
8e6843d
chore: Remove unused role, actor, and task information plugins
LeChatP Apr 21, 2024
808d1b8
feat: Add PAM authentication with custom prompt
LeChatP Apr 21, 2024
789ea05
chore: Add panic hook for syslog tracing
LeChatP Apr 21, 2024
52042fd
Refactor code to improve error handling and logging
LeChatP Apr 21, 2024
b164e03
Change configure.sh to use JSON file for rootasrole configuration
LeChatP Apr 21, 2024
5cb9523
Add *.profraw to .gitignore
LeChatP Apr 21, 2024
31ee6b4
cargo fix
LeChatP Apr 21, 2024
388f030
Configure script for non sudo execution
LeChatP Apr 26, 2024
f58ba45
Add prompt argument
LeChatP Apr 26, 2024
ef72e49
fix running script files
LeChatP Apr 26, 2024
88fe537
chore: Update reqwest dependency to version 0.12.4
LeChatP Apr 27, 2024
ea55f1e
indent
LeChatP Apr 27, 2024
262dc34
Remove xml file
LeChatP Apr 27, 2024
c07f43e
Fix capable not working #40
LeChatP Apr 27, 2024
f23a9ba
Warns when config file is not immutable
LeChatP Apr 27, 2024
5316c7e
chore: Update to minimal rootasrole.json with ROOTADMINISTRATOR
LeChatP Apr 28, 2024
021f1d9
better task match
LeChatP Apr 28, 2024
29cdadb
better verbosity
LeChatP Apr 28, 2024
983b13b
adding rustfmt each time we build the capability description
LeChatP Apr 28, 2024
5121124
Add book content, refactor, and fixes
LeChatP Apr 28, 2024
e571c10
Improve documentation and fix typos
LeChatP Apr 28, 2024
cb349ac
docs: Update documentation links in CONTRIBUTE.md
LeChatP Apr 29, 2024
1a9a5b3
Add versionning when saving file
LeChatP Apr 29, 2024
a6c7d06
Merge branch 'main' into develop
LeChatP Apr 29, 2024
ff71a56
fix: Update configure.sh to define root role for user during installa…
LeChatP Apr 29, 2024
78b0e74
Update build.yml and quality.yml scripts
LeChatP Apr 29, 2024
a4d455c
Format Rust code using rustfmt
github-actions[bot] Apr 29, 2024
a7718c2
Managing some unexpected cases
LeChatP Apr 29, 2024
8b53cd0
Merge branch 'develop' of github.com:LeChatP/RootAsRole into develop
LeChatP Apr 29, 2024
53f46dc
merge went wrong
LeChatP Apr 29, 2024
6a0ed2c
cargo clippy
LeChatP Apr 29, 2024
b063387
Format Rust code using rustfmt
github-actions[bot] Apr 29, 2024
8be3959
clippy
LeChatP Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
run: sudo apt-get update
- name: Install Dependencies
run: |
sudo ./dependencies.sh -yd
sudo ./configure.sh -yd
echo "/home/runner/.cargo/bin" >> $GITHUB_PATH
- name: Configure PAM
Expand All @@ -31,14 +32,14 @@ jobs:
session requisite pam_permit.so
session required pam_permit.so" | tee /etc/pam.d/sr'
- name: Add read access on config on rootasrole... Because Github Actions...
run: sudo chmod a+r /etc/security/rootasrole.xml
run: sudo chmod a+r /etc/security/rootasrole.json
- name: print config
run: cat /etc/security/rootasrole.xml
run: cat /etc/security/rootasrole.json
- name: getenv
run: env
- name: Install Project
run: sudo -E make -e install
- name: Run Sr
run: /usr/bin/sr -h
- name: Run Chsr
run: /usr/bin/chsr -h
- name: Run Chsr with sr
run: sr /usr/bin/chsr -h
5 changes: 4 additions & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ jobs:
toolchain: stable
components: clippy
override: true

- name: Install Dependencies
run: sudo ./dependencies.sh -yd

- name: Configure
run: sudo ./configure.sh -yd

# if pull request review only
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
run: cargo install grcov

- name: Install Dependencies
run: sudo ./dependencies.sh -yd

- name: Install file configuration
run: sudo ./configure.sh -yd

- name: run tests with coverage
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.elf
*.ll
*.pyc
*.profraw

# Linker output
*.ilk
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"typeinfo": "c"
},
"rust-analyzer.linkedProjects": [
"sudoers-reader/Cargo.toml",
//"sudoers-reader/Cargo.toml",
"Cargo.toml",
"./capable/Cargo.toml"
],
Expand Down
65 changes: 46 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ members = ["xtask", "capable", "capable-common"]

[package]
name = "RootAsRole"
version = "3.0.0-alpha.3"
version = "3.0.0-alpha.4"
rust-version = "1.74.1"
authors = ["Eddie Billoir <[email protected]>"]
edition = "2021"
default-run = "sr"
description = "RootAsRole is an alternative to sudo that uses Linux capabilities and RBAC for scalability."
license-file = "LICENSE"
repository = "https://github.com/LeChatP/RootAsRole"
keywords = ["sudo", "capabilities", "rbac", "linux", "security"]
categories = ["command-line-utilities", "os::linux-apis", "config"]

[badges]
maintainance ={ status = "actively-maintained", badge = "https://img.shields.io/badge/maintenance-actively%20maintained-brightgreen.svg" }


#[features]
#cursive_lib = [ "cursive" ]
Expand All @@ -22,34 +32,51 @@ name = "chsr"
path = "src/chsr/main.rs"

[build-dependencies]
reqwest = { version = "0.11.18", features = ["blocking", "json"] }
reqwest = { version = "0.12.4", features = ["blocking", "json"] }
pcre2 = "0.2.4"
regex = "1.9.1"
serde = { version = "1.0.185" }
serde_json = "1.0.113"

[dependencies]
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
libc = "0.2.139"
semver = "1.0.18"
nix = { version = "0.26.2", features = ["user"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
libc = "0.2.153"
strum = { version = "0.26.2", features = ["derive"] }
semver = { version = "1.0.22", features = ["serde"] }
nix = { version = "0.28.0", features = ["user","process", "signal", "fs"] }
#sudoers-reader = { path = "sudoers-reader" }
clap = { version = "4.3.0", features = ["derive"] }
cursive = { version = "0.20.0", default-features = false, features = ["termion-backend"] }
capctl = "0.2.3"
pcre2 = "0.2.4"
chrono = "0.4.26"
sxd-document = "0.3.2"
sxd-xpath = "0.4.2"
serde = "1.0.185"
ciborium = "0.2.1"
clap = { version = "4.5.3", features = ["derive"] }
capctl = "0.2.4"
pcre2 = "0.2.6"
serde = { version = "1.0.197", features=["rc"] }
serde_json = "1.0.114"
ciborium = "0.2.2"
glob = "0.3.1"
pam-client = { version = "0.5.0" }
bitflags = { version = "2.4.0" }
pam-client = { version = "0.5.0", git = "https://gitlab.com/LeChatP/rust-pam-client.git" }
bitflags = { version = "2.5.0" }
shell-words = "1.1.0"
syslog-tracing = "0.2.0"
syslog-tracing = "0.3.0"
linked_hash_set = { version = "0.1.4" }
derivative = "2.2.0"
sha2 = "0.10.8"
sha1 = "0.10.6"
md5 = "0.7.0"
chrono = "0.4.37"
pty-process = "0.4.0"
once_cell = "1.19.0"
crossterm = "0.27.0"
pest = "2.7.8"
pest_derive = "2.7.8"
phf = { version = "0.11.2", features = ["macros"] }
const_format = "0.2.32"
rpassword = "7.3.1"

[dev-dependencies]
env_logger = "*"
test-log = { version = "0.2.12", features = ["trace"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.16", default-features = false, features = ["env-filter", "fmt"] }
pest-test-gen = "0.1.7"
pest-test = "0.1.6"
lazy_static = "1.4.0"
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ CARGO ?= /usr/bin/cargo
PROFILE ?= release
RELEASE = $(if $(filter $(PROFILE),release),--release,)
BIN_DIR := target/$(PROFILE)
SR_VERSION = $(shell xmllint --xpath "string(/rootasrole/@version)" resources/rootasrole.xml)
BINS := $(addprefix $(BIN_DIR)/,sr chsr capable)
.PHONY: $(BIN_DIR)/sr $(BIN_DIR)/chsr
.PHONY: $(BIN_DIR)/sr $(BIN_DIR)/chsr $(BIN_DIR)/capable
$(BIN_DIR)/sr:
cargo build $(RELEASE) --bin sr
cargo build $(RELEASE) --bin sr || true

$(BIN_DIR)/chsr:
cargo build $(RELEASE) --bin chsr
cargo build $(RELEASE) --bin chsr || true

$(BIN_DIR)/capable:
cargo xtask build-ebpf $(RELEASE)
cargo build --package capable $(RELEASE)
cargo xtask build-ebpf $(RELEASE) || true
cargo build --package capable $(RELEASE) || true

$(BINS): | $(BIN_DIR)

Expand All @@ -25,6 +24,7 @@ build: $(BINS)
install: build
cp -f $(BINS) /usr/bin
setcap "=p" /usr/bin/sr
setcap cap_dac_override,cap_sys_admin,cap_sys_ptrace+ep /usr/bin/capable

test:
cargo test
Expand Down
47 changes: 8 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</p>
<!-- markdownlint-restore -->

# RootAsRole (V3.0.0-alpha.3) : a secure alternative to sudo/su on Linux systems
# RootAsRole (V3.0.0-alpha.4) : a secure alternative to sudo/su on Linux systems

This tool allows you to configure your privilege access management more securely on a single operating system.

Expand All @@ -29,10 +29,11 @@ By using a role-based access control model, this project allows us to better man

Requirement: rustc >= 1.70.0

1. git clone <https://github.com/SamerW/RootAsRole>
2. cd RootAsRole
3. sudo ./configure.sh
4. sudo make install
1. git clone <https://github.com/LeChatP/RootAsRole>
1. cd RootAsRole
1. sudo ./dependencies.sh
1. sudo ./configure.sh
1. sudo make install

Note: The `configure.sh` installs `cargo` and `bpf-linker` rust programs manually into `/usr/local/bin`. You can refuse to install it this way, but these are mandatory to build the program. Depending on your distribution or how you want to install this software, you may know that most rust binaries are installed to `$HOME/.cargo/bin`. When you use sudo to configure, these binaries are installed in the effective user home directory. You may need to move these binaries to a known-user path.

Expand All @@ -52,6 +53,8 @@ Execute privileged commands with a role-based access control system

<u><b>Options</b></u>:
<b>-r, --role</b> &lt;ROLE&gt; Role to select
<b>-t, --task</b> &lt;TASK&gt; Task to select (--role required)
<b>-p, --prompt</b> &lt;PROMPT&gt; Prompt to display
<b>-i, --info</b> Display rights of executor
<b>-h, --help</b> Print help (see more with '--help')
<b>-V, --version</b> Print version
Expand All @@ -62,38 +65,6 @@ If you're accustomed to utilizing the sudo tool and find it difficult to break t
alias sudo="sr"
```

### How to Configure

To configure this program you could use the `chsr` command.

<pre>
Configure Roles for RootAsRole

<u><b>Usage</b></u>: <b>chsr</b> [COMMAND]

<u><b>Commands</b></u>:
<b>list</b> List all roles
<b>newrole</b> Create a new role, you can add users, groups, tasks. You can assign tasks through the command "addtask"
<b>grant</b> You can grant users/groups to role
<b>revoke</b> You can revoke users/groups from role
<b>addtask</b> Add a task to a role, you can add commands and capabilities
<b>deltask</b> Delete a task from a role
<b>delrole</b> Delete a role, this is not reversible
<b>config</b> You could configure options for all roles, specific role, or specific task
<b>import</b> NOT IMPLEMENTED: Import sudoers file
<b>help</b> Print this message or the help of the given subcommand(s)

<u><b>Options</b></u>:
<b>-h, --help</b> Print help (see more with '--help')
<b>-V, --version</b> Print version
</pre>

You could also use the fancy TUI configuration manager :

![Chsr TUI](assets/chsr-tui.png)

This role manager is currently under development and does not provide entire configuration edition. So you can manually execute these commands :

```sh
sr chattr -i /etc/security/rootasrole.xml
sr nano /etc/security/rootasrole.xml
Expand Down Expand Up @@ -150,8 +121,6 @@ As you may know with this RBAC model, it is possible for multiple roles to refer

After these step, if two roles are conflicting, these roles are considered equal (only the environment variables are different), so configurator is being warned that roles could be in conflict and these could not be reached without specifing precisely the role to choose (with `--role` option). In such cases, we highly recommend to review the design of the configured access control.

Regarding the (vii),(viii), and (ix) points, the insecure criteria is somewhat arbitrary. We are working on a explaination on a paper.

## Tested Platforms

Our module has been tested on:
Expand Down
Binary file removed assets/chsr-tui.png
Binary file not shown.
8 changes: 5 additions & 3 deletions book/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

Unlike sudo, this project sets the principle least privilege on its core features. Like sudo, this project wants to be usable. More than sudo, we care about configurators, and we try to warn configurators about dangerous manipulations.

By using a role-based access control model, this project allows us to better manage administrative tasks. With this project, you could distribute privileges and prevent them from escalating directly. Unlike sudo does, we don't want to give entire privileges for any insignificant administrative task, so you could configure it easily with `chsr` command. To find out which capability is needed for a administrative command, we provide the `capable` command. With these two tools, administrators could respect the least privilege principle on their system.
By using a role-based access control model, this project allows us to better manage administrative tasks. With this project, you could distribute privileges and prevent them from escalating directly. Unlike sudo does, we don't want to give entire privileges for any insignificant administrative task. You can configure our tool easily with `chsr` command. To find out which capability is needed for a administrative command, we provide the `capable` command. With these two tools, administrators could respect the least privilege principle on their system.

What we offer that sudo don't :
* [Linux Capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html) managed and simplified
* [Linux Capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html) support
* [A structured access control model based on Roles](https://dl.acm.org/doi/10.1145/501978.501980)
* Command matching based on commonly-used open-source libraries
* [glob](https://docs.rs/glob/latest/glob/) for binary path
* [PCRE2](https://www.pcre.org/) for command arguments
* Standardized file configuration with [JSON](https://www.json.org/)
* Separation of duties.
* Configuration file formatted in XML and with DTD Schema Validation.
* Multi-layered configuration.
* A simple and easy-to-use configuration command line interface.

13 changes: 2 additions & 11 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# User Guide

- [Installation](guide/installation.md)
- [Use RootAsRole](guide/use.md)
- [Configure RootAsRole](guide/configure.md)
- [Configure RootAsRole](chsr/README.md)

# Knowledge Guide

Expand All @@ -20,19 +19,11 @@
# Reference Guide

- [`sr` Command Line Tool](sr/README.md)
- [`chsr` Terminal User Interface](chsr/tui.md)
- [`chsr` Command Line Tool](chsr/README.md)
- [newrole](chsr/newrole.md)
- [grant](chsr/grant.md)
- [revoke](chsr/revoke.md)
- [addtask](chsr/addtask.md)
- [deltask](chsr/deltask.md)
- [delrole](chsr/delrole.md)
- [config](chsr/config.md)
- [import](chsr/import.md)

- [Continuous Integration](continuous-integration.md)
- [How to contribute](dev/CONTRIBUTE.md)
- [Code of Conduct](dev/CODE_OF_CONDUCT.md)

-----------

Expand Down
Loading
Loading