[Solved] Creating a credential for any IP or DNS based only on the port

Good afternoon, I work with network consulting and I’m using bitwarden to manage the credentials of some clients.

Due to the clients’ need, I use the same password for all servers of the same type (firewall has a password for all branches, fileserver, etc.) and each of these services uses a different port to log in, for example:

firewall https://ip-server:10443/
fileserver https://ip-server:8443/

I would like to know if anyone knows if there is any way to create a credential called a firewall where https://: 10443/ it automatically applies the username and password, no matter what IP or DNS is used in the url, only the port?

Regular expressions in the URI match may help:

https://bitwarden.com/help/article/uri-match-detection/#regular-expression

I tried to use regular expression in the following models and it was not:

^https:.:10443.
^https://.*:10443$

In neither case does he recognize the pattern. Do you have any tips to give?

1 Like

Try using ^https:\/\/(.*):10443.
That worked for me when I tested it.

4 Likes

This should have worked for the example you provided.
The final .* is unnecessary as the regex only needs to partially match URI (unless you add end-anchor $).

It would end up matching:

  • https://just.an.example.com:10443
  • https://100.100.100.100:10443/login
  • https://example.com/search?query=foo:10443351

Since $ matches end-of-line, this probably won’t work on browser as there is often an extra slash in URI.

So, this can match https://example.com:10443 but will not match https://example.com:10443/

I wouldn’t recommend excluding the start-of-line anchor ^ since that would allow matches on arbitrary protocols as long as https is included later in the URI, e.g.

  • http://www.google.com/search?q=https://example.com:10443


A specific example (with personal data removed) would be the best way to get further support.

The basic starting regex would be ^https://.*:10443, which should work with the example https://ip-server:10443/

Some modifications from basic regex would be

  • Allow both HTTP + HTTPS: ^https?://.*:10443
  • Restrict to common characters in domain names and IPv4 (doesn’t support IPv6): ^https://[.a-z0-9-]+:10443

The more restrictions you apply, the safer it is to avoid autofilling on unintended (and possibly malicious) sites.

You can tell that your URI match works by seeing counter on Bitwarden extension badge. Whether autofill works is a separate story and will depend on how the HTML on website looks.

4 Likes

I updated my original answer. Good call on the starting anchor. I hadn’t considered that.

2 Likes

Reviewing here and it worked! I should have done something wrong before, I removed the * from the end and it worked! Thank you very much!