make flows more precise

This commit is contained in:
Michael Jerger 2023-12-15 15:37:00 +01:00
parent e1d7db178c
commit 9e6c45f87d

View file

@ -12,15 +12,16 @@ sequenceDiagram
activate os activate os
os ->> os: validate request inputs os ->> os: validate request inputs
activate repository activate repository
os ->> repository: validate os ->> repository: search for reop with object-id
repository ->> repository: search for reop with object-id
deactivate repository deactivate repository
activate person activate user
os ->> person: validate os ->> user: search for user with actor-id
person ->> person: search for ser with actor-id user ->> user: create if not found
person ->> fs: get /api/activitypub/user-id/{id from actor} activate user
person ->> person: create user from response user ->> fs: get /api/activitypub/user-id/{id from actor}
deactivate person user ->> user: create user from response
deactivate user
deactivate user
os ->> repository: execute star action os ->> repository: execute star action
os -->> fs: 200 ok os -->> fs: 200 ok
deactivate os deactivate os
@ -45,7 +46,7 @@ sequenceDiagram
"type": "Star", "type": "Star",
"source": "forgejo", "source": "forgejo",
"actor": "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1", "actor": "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1",
"object": "https://codeberg.org/api/v1/activitypub/repository-id/1" "object": "https://codeberg.org/api/v1/activitypub/repository-id/12"
} }
``` ```
@ -55,9 +56,8 @@ sequenceDiagram
flowchart TD flowchart TD
A(User) --> |stars a federated repository| B(foreign repository server) A(User) --> |stars a federated repository| B(foreign repository server)
B --> |Star Activity| C(our repository server) B --> |Star Activity| C(our repository server)
C --> |get repository localy| D(our repos database) C --> |get Person Actor| B
C --> |get Person Actor| B C --> |create federated user localy| D(our database)
C --> |create federated user localy| D
C --> |add star to repo localy| D C --> |add star to repo localy| D
``` ```
@ -78,8 +78,15 @@ flowchart TD
1. Script Kiddi sends a Star Activity containing an attack actor url `http://attacked.target/very/special/path` in place of actor. Our repository server sends an `get Person Actor` request to this url. The attacked target gets DenialdOffServices. We loose CPU & reputation. 1. Script Kiddi sends a Star Activity containing an attack actor url `http://attacked.target/very/special/path` in place of actor. Our repository server sends an `get Person Actor` request to this url. The attacked target gets DenialdOffServices. We loose CPU & reputation.
2. Experienced hacker sends a Star Activity containing an actor url pointing to an evil forgejo instance. Our repository server sends an `get Person Actor` request to this instance and get a person having sth. like `; drop database;` in its name. If our server tries to create a new user out of this persion, the db might be droped. 2. Experienced hacker sends a Star Activity containing an actor url pointing to an evil forgejo instance. Our repository server sends an `get Person Actor` request to this instance and get a person having sth. like `; drop database;` in its name. If our server tries to create a new user out of this persion, the db might be droped.
3. OpenSource Promoter sends Star Activities having not authorized Person Actors. The Actors listed as stargazer migth get angry about this, we loose reputation. 3. OpenSource Promoter sends Star Activities having not authorized Person Actors. The Actors listed as stargazer migth get angry about this, we loose reputation.
4. Experienced Hacker records activities sent and replays some of them. Without order of activities (i.e. timestamp) we can not decide wether we should execute the activity again. If activity is Unstar Activity we might loose stars. 4. Experienced Hacker records activities sent and replays some of them. Without order of activities (i.e. timestamp) we can not decide wether we should execute the activity again. If the replayed activities are Unstar Activity we might loose stars.
4. Experienced Hacker records activities sends a massive amount of activities which leads to new user storage. Our instance might get off service. 5. Experienced Hacker records activities sends a massive amount of activities which leads to new user creation & storage. Our instance might get off service.
### Mitigations
1. Validate object uri in order to send only requests to well defined endpoints.
2. giteas global SQL injection protection. TODO: verify if there is one.
3. We accept only signed Activities
4. We accept only activities having an timestamp & remember the last executed activity timestamp.
5. ...
### DREAD-Score ### DREAD-Score