So, the best approach for this kind of problems is to create pull requests to the libraries and get them pulled into upstream, so that they can maintain the code and we can use the code maintained by them and have all features we need without private forks.
I would like to just implement the required changes and create PRs when necessary, then use the upstream libraries in my work. However, my agreement (expectably) says that all the code that I create at work belongs to the employer, so right now I'm trying to create PRs on weekends to not get into troubles. My boss agrees that it is a problem and said that we can modify my agreement.
Although I understand that I need a lawyer the country where the company is registered to do actual modification of the agreement in a lawful way, I'm curious how is this kind of problems is solved in other companies and what keywords can be used to get more information about this.
I find GitHub's Balanced Employee Intellectual Property Agreement [1] somewhat close to what I want, but I find it to be not exactly clear that it would allow me to commit to open source projects that I use at work because in my understanding each feature that I might add to an open source project and then use in the company's code base can be counted as "(ii) developed for use by the Company".
[1] https://github.com/github/balanced-employee-ip-agreement/blob/master/Balanced_Employee_IP_Agreement.md