Bug 1219688

Summary: AUDIT-0: agama: agama web server
Product: [openSUSE] openSUSE Tumbleweed Reporter: Imobach Gonzalez Sosa <igonzalezsosa>
Component: SecurityAssignee: Paolo Perego <paolo.perego>
Status: NEW --- QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: paolo.perego
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Imobach Gonzalez Sosa 2024-02-07 21:53:29 UTC
Hi all,

Until now, the Agama web user interface relied on Cockpit to communicate with the Agama D-Bus services. For several reasons[1], we decided to drop our dependency on Cockpit and build an HTTP-based service.

The idea is that not only the web user interface, but any client (e.g., Agama's CLI), would connect to this new server, which will hide many D-Bus details and will offer a higher-level API.

The server would run as root (as the D-Bus services). About the communication client/server:

* It will always be encrypted (over SSL) except when connected from localhost.
* The client will log in with a user/password (using PAM).
* The server will generate a token the client will use in the following requests (probably a JWT[2], although it is still undecided).
* We do not plan to persist the tokens by now: once the service is shut down, the client must authenticate again. However, we might consider saving them to make development easier.

Please remember that this service will only run in the Agama installation media, as it is not supposed to run on an installed system (only for development).

So I have opened this bug report to check with you if we should have something else into account or if we are already doing something wrong.

Thank you in advance!

Regards,
Imo
Comment 1 Matthias Gerstner 2024-02-08 08:46:06 UTC
Can you please point us to the package / source used for this?

Is there an installation media available where this is already integrated?

Note: we reviewed the agama installer last in bug 1208394.
Comment 2 Imobach Gonzalez Sosa 2024-02-08 11:13:29 UTC
Hi Matthias,

We have no code yet. Just wanted to know if there was anything flawed in the approach. We expect to have something working during the following weeks. If you prefer, I would close this issue and reopen it when there is some real code to check.

Is it ok?

Thanks!
Comment 3 Matthias Gerstner 2024-02-08 14:06:28 UTC
Ah okay, I missed that bit, that this is only in the design phase yet.

Since this will be using TLS, how will the certificate trust be handled? With
self-signed certificates some form of fingerprint verification would need to
happen.

Otherwise the main worry for this component will continue to be that nobody
can access the system over the network at any stage without authentication of
some form.

I will ask a colleague of mine, Paolo, to chime in. He's a specialist for web
APIs.
Comment 4 Imobach Gonzalez Sosa 2024-02-08 14:32:32 UTC
Hi Matthias,

Yes, you are right. We must display the fingerprint somehow and/or allow the users to inject their certificates. It is pretty similar to the current version based on Cockpit.

I'm looking forward to Paolo's input!

Thanks!
Comment 5 Paolo Perego 2024-02-08 15:10:28 UTC
Hi everybody. Just some random inputs for JWT.
Please make sure to sign or encrypt the token with JWT specific facilities, transferring it only on HTTPS and if you will store it in a cookie to set it as HttpOnly and Secure.

There is also a Owasp provided cheatsheet for JWT tokens you can find here: https://cheatsheetseries.owasp.org/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html

Another point of attention is for digital cerficate. Please make sure to let the client validate the certificate when doing HTTPS calls. However I didn't understand the scenario... both client and server will run on the same host, correct?
Comment 6 Imobach Gonzalez Sosa 2024-02-08 15:30:43 UTC
(In reply to Paolo Perego from comment #5)

Hi Paolo,

> Hi everybody. Just some random inputs for JWT.
> Please make sure to sign or encrypt the token with JWT specific facilities,
> transferring it only on HTTPS and if you will store it in a cookie to set it
> as HttpOnly and Secure.

OK, noted.

> There is also a Owasp provided cheatsheet for JWT tokens you can find here:
> https://cheatsheetseries.owasp.org/cheatsheets/
> JSON_Web_Token_for_Java_Cheat_Sheet.html

Thanks! We will have a look.

> Another point of attention is for digital cerficate. Please make sure to let
> the client validate the certificate when doing HTTPS calls. However I didn't
> understand the scenario... both client and server will run on the same host,
> correct?

Which is the right way to validate the certificate? Allowing the user to check the fingerprint?

The client and the server might run on different machines. You can install the system locally (using a browser that runs on the same machine and connects to "localhost") or remotely using your browser.

Following Cockpit's approach, when connecting to localhost, we do not see the need to use HTTPS. But when installing remotely, it is mandatory. Does it make sense?

Regards,
Imo
Comment 7 Paolo Perego 2024-02-08 16:29:17 UTC
(In reply to Imobach Gonzalez Sosa from comment #6)
> (In reply to Paolo Perego from comment #5)

[snip]

> > Another point of attention is for digital cerficate. Please make sure to let
> > the client validate the certificate when doing HTTPS calls. However I didn't
> > understand the scenario... both client and server will run on the same host,
> > correct?
> 
> Which is the right way to validate the certificate? Allowing the user to
> check the fingerprint?
Ok well... interacting with the browser, using a valid certificate, not self signed. Interacting with a command line client, having the client validating all the root of trust of the certificate.

eg:

> import requests
> requests.post(url='https://foo.example', data={'bar':'baz'})

> Following Cockpit's approach, when connecting to localhost, we do not see
> the need to use HTTPS. But when installing remotely, it is mandatory. Does
> it make sense?
It would require a lot of extra effort dividing the two cases... however it makes sense to have http on a localhost only communication.
Comment 8 Imobach Gonzalez Sosa 2024-02-09 06:46:32 UTC
(In reply to Paolo Perego from comment #7)

[..]

> Ok well... interacting with the browser, using a valid certificate, not self
> signed. Interacting with a command line client, having the client validating
> all the root of trust of the certificate.

Well, bear in mind that you do not know the name or IP address the system will use when running (after all, it is a live DVD). What we do these days in Agama is to use a self-signed certificate (generated by Cockpit) and allow the user to use his/her own certificate (specifying a URL to get the certificate as a kernel cmdline option).

Not to mention than using a proper certificate would need you to distribute such a certificate (including the private key) in the media.

Or perhaps the problem is that I am lost :-)

> eg:
> 
> > import requests
> > requests.post(url='https://foo.example', data={'bar':'baz'})
> 

[..]
Comment 9 Paolo Perego 2024-02-12 14:24:25 UTC
(In reply to Imobach Gonzalez Sosa from comment #8)
> (In reply to Paolo Perego from comment #7)

[snip]

> Well, bear in mind that you do not know the name or IP address the system
> will use when running (after all, it is a live DVD). What we do these days
> in Agama is to use a self-signed certificate (generated by Cockpit) and
> allow the user to use his/her own certificate (specifying a URL to get the
> certificate as a kernel cmdline option).

Correct.

I will take in charge this audit. Can you please share with me a roadmap to understand when the code will be available to audit?
So I can schedule the activities.

Thank you
Paolo
Comment 10 Imobach Gonzalez Sosa 2024-02-14 07:36:40 UTC
Hi Paolo,

Thanks a lot for having a look. Our (now updated) roadmap is in Confluence:

https://confluence.suse.com/display/YAST/Project+Roadmap

The changes should be included in milestone 1 (mid-April), but we can report on the progress as soon as we start working (this week).

Regards,
Imo
Comment 11 Michal Filka 2024-04-29 09:54:56 UTC
Docs about security concepts in agama: https://github.com/openSUSE/agama/blob/architecture_2024/doc/agama-security.md
Comment 12 Imobach Gonzalez Sosa 2024-05-09 13:46:37 UTC
Hi everyone,

We have moved the security concepts documentation to a new location[1]. Additionally, we have reorganized all the documentation a bit, and we have updated the description of the architecture[2].

We are working on building a new ISO image containing the latest code. I will ping you when it is ready.

[1] https://github.com/openSUSE/agama/blob/master/doc/security.md
[2] https://github.com/openSUSE/agama/blob/master/doc/architecture.md
Comment 13 Paolo Perego 2024-05-14 06:01:46 UTC
(In reply to Imobach Gonzalez Sosa from comment #12)
> Hi everyone,
> 
> We have moved the security concepts documentation to a new location[1].
> Additionally, we have reorganized all the documentation a bit, and we have
> updated the description of the architecture[2].
> 
> We are working on building a new ISO image containing the latest code. I
> will ping you when it is ready.
> 
> [1] https://github.com/openSUSE/agama/blob/master/doc/security.md
> [2] https://github.com/openSUSE/agama/blob/master/doc/architecture.md

Thanks
Comment 14 Imobach Gonzalez Sosa 2024-07-19 13:52:51 UTC
Hi all,

The new code has been included in the official image for quite some time already, so perhaps you might want to have a look. The documents in comment 12 still apply.

You can grab a new image at https://download.opensuse.org/repositories/systemsmanagement:/Agama:/Devel/images/

Thanks!