Skip to content

/models and /routes Exposed To All Environments #1124

Closed

Description

@greaterweb

I'm pretty curious as to why /models and /routes are exposed to all environments (in most cases, it would be at /api/models and /api/routes. Maybe this is something that could be useful for some sort of development/tooling purpose but I struggle a bit to find a reason why this is open.

To compound the issue, how it's implemented you can make any request type to the endpoint including GET, POST, PUT, DELETE.

If there is a valid reason to keep these endpoints exposed, at the minimum an option should be made available to toggle the visibility.

Activity

  1. greaterweb commented on Feb 24, 2015

    @greaterweb
    ContributorAuthor

    Temporary fix to disable the routes:

    If default, generated loopback setup which includes /server/boot/rest-api.js:

    module.exports = function mountRestApi(server) {
      var restApiRoot = server.get('restApiRoot');
      server.use(restApiRoot + '/models', function (req, res) {
        res.send(404);
      });
      server.use(restApiRoot + '/routes', function (req, res) {
        res.send(404);
      });
      server.use(restApiRoot, server.loopback.rest());
    };
  2. superkhau commented on Feb 25, 2015

    @superkhau
    Contributor
  3. greaterweb commented on Feb 25, 2015

    @greaterweb
    ContributorAuthor

    Ouch.

    My questioning of the role these endpoints serve don't exactly invalidate the security implications here.

    Take /api/routes for example, the response exposes all public endpoints including, HTTP method, accepted parameters and the loopback method that is invoked. I can't think of one good use case on why I would ever want to do this on a public facing site. This just seems like an open invitation for potential abuse.

    The fact I can GET, POST, PUT and DELETE to these endpoints concerns me as well, that's not consistent with a feature/functionality that's been completely thought through.

    Initially I thought this was something that was part of/consumed by loopback-explorer but that doesn't seem to be the case.

    Whatever role they serve, the potential for abuse seems pretty high.

    @bajtos you've be helpful with previous issues I've reported and contributed to before, could you please weigh in on this one? Maybe I'm way off the mark with this one but would like your input before dismissing the validity of this ticket.

    Here are some sample responses to review from a clean LB app with a Widget model added.

  4. bajtos commented on Feb 25, 2015

    @bajtos
    Member

    I agree the security implications should be considered.

    @raymondfeng @ritch do you remember why these routes were added?

    @greaterweb Would you mind contributing the toggle for disabling these routes yourself?

  5. reopened this on Feb 25, 2015
  6. ritch commented on Feb 25, 2015

    @ritch
    Member

    Whatever role they serve, the potential for abuse seems pretty high.

    These are used (or at least were) by the explorer. We should support some option to remove them or even better just move them to the explorer middleware and then if you disable the explorer you disable these routes.

    I'm closing this issue in favor of an actionable one: #1134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions