We have some RESTful API services that we have been using for several years. Recently we have started considering surfacing these to 3rd party clients so they can write their own UIs and we can work on building up this service layer. Unfortunately this would mean that we would not have control over enforcing that data is sanitized before posting, or before rendering which leaves a potential risk for XSS (for example if someone were to post data with JavaScript in a textarea that might be saved to the DB).
Our stack is Apache, Tomcat and Java.
Does anyone know of a way to put some kind of filter out in front of these existing API endpoints that could handle sanitizing data both inbound and outbound (altho inbound is probably most important)? As mentioned these are long standing APIs that weren't publicly accessible so we had been handling this at the UI layer, but we would like to avoid having to rewrite every existing endpoint to handle sanitization if possible.