You are missing my point completely. Can Russia attack a Ukrainian ship in a British port? If Ukraine can attack a Russian ship in a Libyan port, then what is the difference??
You ask a very important question and for this first we need to visit a particular document known as the Hague Convetion:

Russia is a signatory of the convention:

---
What does the convention state:

...
Why is this important?
1. Libya isn’t even a party to the 1907 Hague Convention XIII.
2. Article 28 expressly limits the Convention’s application to contracting powers.

3. That said customary international law still protects neutral waters irrespective of treaty membership.
4. The very same convention imposes obligations on neutral countries and visiting warships.
- Article 5: Neutral ports must not be used as bases for naval operations against an adversary.
- Article 9: Restrictions must be applied impartially to both belligerents.
- Article 12: Warships generally cannot remain in neutral ports longer than 24 hours, subject to exceptions.
- Article 14: Warships cannot prolong their stay beyond the permitted time except due to damage or adverse weather.
- Article 18: Replenishing armaments, war matériel and crews is prohibited.
- Article 19: Refuelling and resupply are restricted.
- Article 25: Neutral countries must take available measures to prevent violations of neutrality.
According to Reuters, the Russian warship had been docked in Benghazi for several days, refuelling and resupplying under a military cooperation agreement while escorting Russian cargo ships capable of transporting military supplies.
Source:
https://www.reuters.com/world/middl...ack-caused-explosion-russian-ship-2026-11-22/
Russia therefore appears to have breached the neutrality rules reflected in Articles 12 and 14,
unless a valid exception applied. Its activities also raise legitimate questions
under Articles 1, 5, 18 and 19.
Paragraph 22 of the 1994 San Remo Manual provides for circumstances in which a belligerent may use strictly necessary defensive force against an adversary violating neutral waters, provided the violation poses a serious and immediate threat and no feasible alternative exists.
[Source:
https://ihl-databases.icrc.org/en/ihl-treaties/san-remo-manual-1994]
Does this automatically establish the legality of Ukraine’s attack?
No.
Does this mean Russian can attack beligerent vessels in neutral ports like say for example British, Bulgarian or Greek ports?
NO
Would a Russian attack on on a Ukrainian or Neutral vessel docked at a port of a NATO country automatically trigger article 5?
NO*
* the exception here is that it would create an immediate security crisis, and should the NATO nation's infrastructure be damaged or its personnel killed then that nation could argue that its sovereignty has been violated and constitute it an armed attack, but it is worth mentioning that there is no "Automatic Trigger" in NATO, which is why Article 4 exists.