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

Add iptlite packet filter app #1399

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

duduita
Copy link

@duduita duduita commented Nov 7, 2022

Summary

This merge request aims to add a lightweight packet filter to NuttX, called iptlite (iptables lite), which was based on Linux firewall, iptables and netfilter. This first implementation was focused on the essential commands, such as adding a drop rule based on the 4-tuple (source IPv4 address, destination IPv4 address, source port and destination port), flush all rules and list all rules, for all ingress TCP packets.

The implementation was divided in two parts: the iptlite app, the CLI to the user, and the nflite modules (netfilter lite), which will provide the APIs to the iptlite app, that can be seen in another MR on the incubator-nuttx repository.

This project was considered the third-best security tool in the XXII Brazilian Symposium on Information Security and Computer Systems, and the related paper was accepted by this conference as well.

Impact

This lightweight packet filter could be an additional security feature, especially in the IoT environment, allowing the users to adopt, for instance, a zero trust policy, consequently, denying all ingress packet filter, except by the preset ones.

Testing

In order to give more context about the implementation that it was made, this following link will show a quick video demo of the project.

@wengzhe
Copy link
Contributor

wengzhe commented Nov 7, 2022

Shall we isolate between iptlite(user space) and nflite(kernel space), using ioctl or setsockopt(iptables uses)?

Comment on lines +40 to +41
void add_rule(int rule, char * srcip, char * destip, char * srcprt, \
char * destprt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
void add_rule(int rule, char * srcip, char * destip, char * srcprt, \
char * destprt)
void add_rule(int rule, FAR char *srcip, FAR char *destip, FAR char *srcprt,
FAR char *destprt)

Comment on lines +43 to +44
in_addr_t srcipaddr, destipaddr;
in_port_t srcport, destport;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
in_addr_t srcipaddr, destipaddr;
in_port_t srcport, destport;
in_addr_t srcipaddr;
in_addr_t destipaddr;
in_port_t srcport;
in_port_t destport;

void listall_rules(void)
{
int rules_counter = nflite_get_rules_counter();
char** table = nflite_listall();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
char** table = nflite_listall();
FAR char** table = nflite_listall();

* Included Files
****************************************************************************/

#include "../../../nuttx/net/devif/devif.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we somehow overcome this?

@@ -0,0 +1,94 @@
/****************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

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

license header is missing

@duduita duduita marked this pull request as draft November 7, 2022 17:58
@duduita
Copy link
Author

duduita commented Nov 7, 2022

Shall we isolate between iptlite(user space) and nflite(kernel space), using ioctl or setsockopt(iptables uses)?

We will look into the possibility of using one of these in our implementation. Then, I converted this PR to a draft in the meantime.

@xiaoxiang781216
Copy link
Contributor

@duduita @wengzhe has developed an infrastructure for iptable, you may port filter functionality less effort now. Please reference the follow PR to learn the usage: #1479 and apache/nuttx#7989.

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

Successfully merging this pull request may close these issues.

4 participants