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

Introduce documentation about required capabilities #1587

Merged
merged 7 commits into from
Feb 6, 2025

Conversation

rafaelroquetto
Copy link
Contributor

First iteration of the documentation that talks about the required capabilities to run Beyla. Whilst it could have been nice, a per-kernel list is out of the scope for this PR and could be added later.

I've also removed the mentions to mounting file systems, since Beyla no longer does that.

It would be good to get feedback on whether we still require container.apparmor.security.beta.kubernetes.io/beyla: "unconfined".

Resolves #1404

@rafaelroquetto rafaelroquetto added the documentation Improvements or additions to documentation label Jan 29, 2025
@rafaelroquetto rafaelroquetto requested a review from a team January 29, 2025 19:58
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/_index.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.05%. Comparing base (53ed88f) to head (9407e75).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1587      +/-   ##
==========================================
+ Coverage   63.86%   67.05%   +3.19%     
==========================================
  Files         196      197       +1     
  Lines       19862    19871       +9     
==========================================
+ Hits        12684    13325     +641     
+ Misses       6381     5858     -523     
+ Partials      797      688     -109     
Flag Coverage Δ
integration-test 52.48% <ø> (-0.24%) ⬇️
k8s-integration-test ?
oats-test 34.64% <ø> (-0.02%) ⬇️
unittests 47.06% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
| Capability | Usage in Beyla |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| `CAP_BPF` | enables general BPF functionality and `BPF_PROG_TYPE_SOCK_FILTER` programs |
| `CAP_NET_RAW` | used to create `AF_PACKET` raw sockets |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is needed for the socket filter program. I think we need to be more descriptive here about how the capabilities relate to Beyla features, I don't think our users would know what AF_PACKET means in terms of Beyla. Same for NET_ADMIN, we need to say network observability and context propagation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I will reshuffle this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, revisiting this, the reason it's written this way is so that it also serves as a guide for power-users/developers. I feel just saying "required for network observability" does not tell the whole story for those who are actually interested on why Beyla needs a particular permission.
I will try to rephrase this to include both an user friendly explanation whilst keeping the technical details for those interested.

docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
### Flow fetcher (tc)
- `CAP_BPF`
- `CAP_NET_ADMIN` -> for `PROG_TYPE_SCHED_CLS`
- `CAP_PERFMON` -> direct access to `struct __sk_buff::data` and pointer arithmetic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again we need to say what this means for our end users.

docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/setup/kubernetes.md Outdated Show resolved Hide resolved
docs/sources/setup/kubernetes.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
docs/sources/security.md Outdated Show resolved Hide resolved
@grafsean grafsean self-assigned this Feb 3, 2025

# Beyla security, permissions, and capabilities

Beyla needs access to various Linux interfaces to instrument applications, such as reading from the `/proc` filesystem, loading eBPF programs, and managing network interface filters. Many of these operations require elevated permissions. The simplest solution is to run Beyla as `root`, however this might not work well in setups where full `root` access isn’t ideal. To address this, Beyla is designed to use only the specific Linux kernel capabilities needed for its current configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.SmartQuotes] Avoid smart quotes in the source file, especially in code blocks. Replace all smart double quotes like or with ". Replace all smart single quotes like , , or ʼ with '. In some contexts, Unicode characters aren't supported and break configurations. The website renders paired quotes using smart quotes in paragraphs.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@grafsean
Copy link
Contributor

grafsean commented Feb 3, 2025

@rafaelroquetto I pushed a copy edit and addressed some of the non-technical feedback. It's ready for you to review and address the remaining technical feedback.

| `CAP_BPF` | Enables general BPF functionality and socket filter (`BPF_PROG_TYPE_SOCK_FILTER`) programs, used for capturing network flows in *network observability mode*. |
| `CAP_NET_RAW` | Used to create `AF_PACKET` raw sockets, which is the mechanism used to attach socket filter programs used for capturing network flows in *network observability mode*. |
| `CAP_NET_ADMIN` | Required to load `BPF_PROG_TYPE_SCHED_CLS` TC programs - these programs are used for capturing network flows and for trace context propagation, both for *network and application observability*. |
| `CAP_PERFMON` | Used for trace context propagation, general *application observability* and network flow monitoring. Allows direct packet access by TC programs, loading eBPF probes in the kernel and pointer arithmetic used by these programs. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Grafana.GoogleSpacing] 'g. A' should have one space.

For more information, refer to https://developers.google.com/style/sentence-spacing.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.


## Internal eBPF tracer capability requirement reference

Beyla's internal architecture is made of different "tracers" - a set of eBPF programs that implement the underlying functionality used by Beyla. A tracer may load and use different kinds of eBPF programs, each requiring their own set of capabilities.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Grafana.ProductPossessives] Don't form a possessive from a feature name, product name, or trademark, regardless of who owns it. Instead, use the name as a modifier or rewrite to use a word like of to indicate the relationship.

For more information, refer to https://developers.google.com/style/possessives#product,-feature,-and-company-names.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.


By carefully choosing and assigning capabilities you can lower the risk of privilege escalation while still letting processes do what they need to.

More information can be found in the [capabilities manpage](https://man7.org/linux/man-pages/man7/capabilities.7.html).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Grafana.Spelling] Did you really mean 'manpage'? The Grafana dictionary might not know of this word yet. To add a new word, refer to Add words to the Grafana Labs dictionary. Alternatively, raise an issue and a maintainer will add it for you. For UI elements, use bold formatting. The spell checker doesn't check words with bold formatting. For paths; configuration; user input; code; class, method, and variable names; statuscodes; and console output, use code formatting. The spell checker doesn't check words with code formatting.

If the rule is incorrect or needs improving, report an issue.

If you have reason to diverge from the style guidance, to skip a rule, refer to Skip rules.

@rafaelroquetto
Copy link
Contributor Author

@grafsean done - could you take yet another look, as I've added more text trying to better contextualise things based on the feedback I got from @grcevski and @marctc ?

@grafsean
Copy link
Contributor

grafsean commented Feb 6, 2025

@rafaelroquetto LGTM 🎉

@rafaelroquetto
Copy link
Contributor Author

Rebased and resolved conflict.

@rafaelroquetto rafaelroquetto merged commit 62aad1f into main Feb 6, 2025
11 of 13 checks passed
@rafaelroquetto rafaelroquetto deleted the security_docs branch February 6, 2025 15:25
Copy link
Contributor

github-actions bot commented Feb 7, 2025

Hello @grafsean!
Backport pull requests need to be either:

  • Pull requests which address bugs,
  • Urgent fixes which need product approval, in order to get merged,
  • Docs changes.

Please, if the current pull request addresses a bug fix, label it with the type/bug label.
If it already has the product approval, please add the product-approved label. For docs changes, please add the type/docs label.
If the pull request modifies CI behaviour, please add the type/ci label.
If none of the above applies, please consider removing the backport label and target the next major/minor release.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs] Security (root access, privileged mode, Linux capabilities)
4 participants