Skip to content

Conversation

@yangfl
Copy link
Contributor

@yangfl yangfl commented Jul 1, 2024

UPnP rules now may have an optional regex filter on requester's descriptions. This is a countermeasure against some UPnP exploiters without shutting down UPnP service completely, albeit they can bypass it by reporting innocent's descriptions maliciously.

Since the filter specifier is optional, existing valid config files will still work.

This increases the executable's size by 1.3 kB from original 147.7 kB on i386.

Maintainer:
Compile tested: i386 snapshot
Run tested: i386 snapshot

@neheb
Copy link
Contributor

neheb commented Jul 1, 2024

Hilarious.

So several days ago, I got an email with a similar changeset that ended up in my spam folder for whatever reason. My suspicion is someone does not want to use a real name.

@yangfl
Copy link
Contributor Author

yangfl commented Jul 2, 2024

Interesting.

PKG_MAINTAINER:=David Yang <mmyangfl@gmail.com>

Why my name suddenly becomes 'not my real name'.

@BKPepe
Copy link
Member

BKPepe commented Jul 2, 2024

Commit description is missing for both commits according to https://openwrt.org/submitting-patches. Would be good to know why do we need to enable regex filter and also the size difference of that package.

Update to 2.3.7, and remove patches which are already in upstream.

Signed-off-by: David Yang <mmyangfl@gmail.com>
UPnP rules now may have an optional regex filter on requester's
descriptions. This is a countermeasure against some UPnP exploiters
without shutting down UPnP service completely, albeit they can bypass it
by reporting innocent's descriptions maliciously.

Since the filter specifier is optional, existing valid config files will
still work.

This increases the executable's size by 1.3 kB from original 147.7 kB on
i386.

Signed-off-by: David Yang <mmyangfl@gmail.com>
@1715173329
Copy link
Member

seems good to go

@BKPepe BKPepe merged commit c51ecd6 into openwrt:master Jul 31, 2024
@yangfl yangfl deleted the miniupnpd branch August 1, 2024 14:26
@Neustradamus
Copy link

@Self-Hosting-Group
Copy link
Contributor

Hi @yangfl

A few minor comments on the implemented PR that I consider important:

Since the filter specifier is optional, existing valid config files will still work.

  1. Have you checked how the daemon config file is generated in init? Isn't there a conflict with the comment field?
  2. Have you checked whether the option works with OpenWrt at all after implementation, when using a custom config file? My quick test showed that the added option does not work.

@yangfl
Copy link
Contributor Author

yangfl commented Jul 31, 2025

Actually, it works - by not working. It's an upstream bug and should be fixed there.

@Self-Hosting-Group
Copy link
Contributor

Actually, it works - by not working. It's an upstream bug and should be fixed there.

But if it works, we have a new issue. With the comment in place of the regular expressions. Correct?

@yangfl
Copy link
Contributor Author

yangfl commented Jul 31, 2025

Yes but as long as upstream does not fix it, everything would be fine. I think this could be fixed quickly

--- a/net/miniupnpd/files/miniupnpd.init
+++ b/net/miniupnpd/files/miniupnpd.init
@@ -39,7 +39,8 @@ conf_rule_add() {
        # Make a single IP IP/32 so that miniupnpd.conf can use it.
        [ "${int_addr%/*}" = "$int_addr" ] && int_addr="$int_addr/32"
 
-       echo "$action $ext_start${ext_end:+-}$ext_end $int_addr $int_start${int_end:+-}$int_end #$comment"
+       echo "#$comment"
+       echo "$action $ext_start${ext_end:+-}$ext_end $int_addr $int_start${int_end:+-}$int_end"
 }
 
 upnpd_write_bool() {

@Self-Hosting-Group
Copy link
Contributor

Since you are suggesting an upstream fix, why not just ignore the regular expression if the fifth token starts with a #? I think this is the better option, as I find the ACL entry comments in the daemon config file are useful.

@yangfl
Copy link
Contributor Author

yangfl commented Jul 31, 2025

Making '#' an exception introduces inconsistency. What if more features are add later?

Alternatively if separating comments is not feasible (which I could't get the point here), simply provide an empty token here ("" or '') will work.

@Self-Hosting-Group
Copy link
Contributor

Making '#' an exception introduces inconsistency. What if more features are add later?

Considering that the daemon is more than two decades old and the ACL entries have not changed, I don't think this will happen. Even when using #, it can be distinguished from a regular expression that starts with "#....

With the current package PR in preparation, there are even more ACL comments where adding an extra line would bloat the file. If you would agree to the suggestion, I could rework the daemon config generation so that if the ACL comment starts with a ", a # is not generated. This would also make your "half" implemented regular expression filter option accessible through the LuCI UI.

@yangfl
Copy link
Contributor Author

yangfl commented Jul 31, 2025

Ok, let's make '#' a terminator.

But I don't think embed reg filter, or anything meaningful into ACL comment is a good idea. Eventually it should get its own option someday.

@Self-Hosting-Group
Copy link
Contributor

Self-Hosting-Group commented Sep 29, 2025

Ok, let's make '#' a terminator.

Cool, thanks.

But I don't think embed reg filter, or anything meaningful into ACL comment is a good idea.
Eventually it should get its own option someday.

I've reconsidered. I have created a separate UCI (and LuCI UI) option, for this (Description filter descr_filter). However, I don't think the workaround offered by the option is complete yet, as it would also be helpful to filter by the client's User-Agent SOAP header as the current filter can only be used with IPv4 and UPnP IGD.

Thanks for your downstream PR. If I understand your PR correctly, this will then be accepted:

allow 1024-65535 0.0.0.0/0 1024-65535 "regex" # comment
allow 1024-65535 0.0.0.0/0 1024-65535 "" # comment
allow 1024-65535 0.0.0.0/0 1024-65535 # comment

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.

6 participants