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

Flowspec matches for unassigned protocols or imp types and codes #1156

Open
adrian62 opened this issue Apr 21, 2023 · 4 comments
Open

Flowspec matches for unassigned protocols or imp types and codes #1156

adrian62 opened this issue Apr 21, 2023 · 4 comments
Assignees

Comments

@adrian62
Copy link

We use flowspec mostly for blocking or mitigating various kinds of attacks. As such, often we want to match traffic whose header fields may not always be 'valid' in the sense that a specific meaning is not assigned to them. Attackers don't necessarily follow standards :)
Take for example protocols: there are many values that are not assigned.
Exabgp allows us to specify the protocol (or ICMP types and codes) by value (in my example 15), but when we receive such a route from the api we get something like =unknown protocol type 15.

While this is useful for a user interface or human reading logs, it requires exception code to handle the unassigned values.

Describe the solution you'd like
I am asking for guidance for creating a patch to eliminate the unknown ... type text and just leaving the expression, in the example above =15 meaning to match exactly protocol 15.

Describe alternatives you've considered
Exception code receiving from the exabgp API can look for unknown ... and remove it, leaving just the operator(s) and value.

Additional context
If others would have interest maybe this could be made a configurable option.

@thomas-mangin
Copy link
Member

Please provide a example packet if you can

@adrian62
Copy link
Author

Thanks for looking, using a sample config like this:

 flow {
        route test_RL {
               rd 0:0;
               match {
                     protocol =15;
               then {
                     discard;
               }
         }
}

Results in this packet going to the peer:

23:50:57 | 10     | outgoing-1      | sending TCP payload (  68) FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0044 0200 0000 2D40 0101 0040 0200 4005 0400 0000 64C0 1008 8006 0000 0000 0000 800E 1100 0186 0000 0B00 0000 0000 0000 0003 810F

And on the peer this is the data received on the API:

INFO:  jsonUpdate:b'{ "exabgp": "4.0.1", "time": 1682121456.9856453, "host" : "BRID2", "pid" : 10, "ppid" : 7, "counter": 24, "type": "update", "neighbor": { "address": { "local": "198.18.21.62", "peer": "198.18.21.30" }, "asn": { "local": 100, "peer": 100 } , "direction": "receive", "message": { "update": { "attribute": { "origin": "igp", "local-preference": 100, "extended-community": [ { "value": 9225060886715039744, "string": "rate-limit:0" } ] }, "announce": { "ipv4 flow-vpn": { "no-nexthop": [ { "protocol": [ "=unknown protocol type 15" ], "rd": "0:0", "string": "flow protocol =unknown protocol type 15 rd 0:0" } ] } } } } } }\n'

@thomas-mangin
Copy link
Member

thomas-mangin commented Apr 22, 2023

cb244de

I am not sure if we should backport to 4.2 as some users may rely on the string as it is (even if it is bad).

Also need to add a test.

@adrian62
Copy link
Author

Thank you, I guess I'll have to try the main branch (5.x?) but pardon my ignorance: in previous versions I passed the environment file with --env but I don't see that option, how do I specify an env file not in the standard location?

M-GQ69FQP39W:exabgp-5 ac1471$ ./sbin/exabgp server --env ~/myenvfile.env ~/myconfig.conf
usage: main.py [-h] {version,cli,healthcheck,env,decode,server,validate} ...
main.py: error: unrecognized arguments: --env

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

No branches or pull requests

2 participants