R2Northstar / NorthstarMasterServer

Master server for Northstar
MIT License
92 stars 33 forks source link

Add ASCII filter #60

Closed emma-miler closed 2 years ago

GeckoEidechse commented 2 years ago

@barnabwhy wanna give it a look? <3

Seems to be working fine so far in prod.

barnabwhy commented 2 years ago

Bad idea this is ngl. Would stop many non-latin alphabetical characters being used

GeckoEidechse commented 2 years ago

Hmmm, given that the set of all Titanfall maps and gamemodes is known, we could actually even go more restrictive for those and limit those to pre-defined values. (Will require master server update though if we add new maps or modes)

For server names I agree that we should allow valid UTF-8 text. Issue is homoglyph attacks to get around word filter etc. Maybe there's a library that handles that?

ASpoonPlaysGames commented 2 years ago

Modded gamemodes exist though

GeckoEidechse commented 2 years ago

Modded gamemodes exist though

True. So I guess keep ASCII requirement for modded gamemodes? Doubt they'll ever include UTF-8.

GeckoEidechse commented 2 years ago

Potential candidate for UTF-8 filter: https://www.npmjs.com/package/utf-8-validate

emma-miler commented 2 years ago

That doesn't actually do what we want it to do. Running that with the data from before, it returns valid. It is checking for a valid utf-8 string from a bytearray.

emma-miler commented 2 years ago

After some more digging, i found the following regex: /[\p{Cc}\p{Cn}\p{Cs}]+/gu from this stackoverflow thread. I ran it against a capture of earlier data and it seems to perfectly match all bad servers, while not including any legit servers. Also tried this with some chinese and japanese glyphs, and those seems to work fine too.

pg9182 commented 2 years ago

Not necessary at the moment, will revisit if an issue arises again.