Skip to content

feat(events): add information on X-Forwarded-For header #907

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
May 6, 2025
Merged

Conversation

bt90
Copy link
Contributor

@bt90 bt90 commented Apr 11, 2025

Describe the event structure if a reverse proxy is involved.

calmh added a commit to syncthing/syncthing that referenced this pull request Apr 23, 2025
### Purpose

Fix #9336

The `emitLoginAttempt` function now checks for the presence of an
`X-Forwarded-For` header. The IP from this header is only used if the
connecting host is either on loopback or on the same LAN.

In the case of a host pretending to be a proxy, we'd still have both IPs
in the logs, which should make this much less critical from a security
standpoint.

### Testing

1. directly via localhost
2. via proxy an localhost

#### Logs

```
[3JPXJ] 2025/04/11 15:00:40 INFO: Wrong credentials supplied during API authorization from 127.0.0.1
[3JPXJ] 2025/04/11 15:03:04 INFO: Wrong credentials supplied during API authorization from 192.168.178.5 proxied by 127.0.0.1
```

#### Event API

```
  {
    "id": 23,
    "globalID": 23,
    "time": "2025-04-11T15:00:40.578577402+02:00",
    "type": "LoginAttempt",
    "data": {
      "remoteAddress": "127.0.0.1",
      "success": false,
      "username": "sdfsd"
    }
  },
  {
    "id": 24,
    "globalID": 24,
    "time": "2025-04-11T15:03:04.423403976+02:00",
    "type": "LoginAttempt",
    "data": {
      "proxy": "127.0.0.1",
      "remoteAddress": "192.168.178.5",
      "success": false,
      "username": "sdfsd"
    }
  }
```

### Documentation

syncthing/docs#907

---------

Co-authored-by: Jakob Borg <jakob@kastelo.net>
@bt90
Copy link
Contributor Author

bt90 commented May 6, 2025

@calmh can we merge here as the changes are already live with v1.29.6?

@calmh
Copy link
Member

calmh commented May 6, 2025

Of course. Y'all don't need to gate everything on me.

@bt90
Copy link
Contributor Author

bt90 commented May 6, 2025

I'd merge if I could 😅 #904 and this PR are both blocked by policy-bot despite having an approval as far as I can see.

@tomasz1986 tomasz1986 changed the title x-forwarded-for feat(events): add information on X-Forwarded-For header May 6, 2025
@bt90 bt90 enabled auto-merge (squash) May 6, 2025 09:51
@bt90 bt90 merged commit 34de465 into main May 6, 2025
3 checks passed
@bt90 bt90 deleted the bt90-patch-2 branch May 6, 2025 09:51
@marbens-arch
Copy link
Member

#904 and this PR are both blocked by policy-bot despite having an approval as far as I can see.

#904 was approved by me before I had write access. policy-bot may not have retroactively counted it.

calmh added a commit that referenced this pull request May 27, 2025
* main: (28 commits)
  chore(config): document options for audit logs (#916)
  chore(advanced): clarify multiple connections over relays (#911)
  fix(specs): state that both A and B are in session mode (fixes #802) (#908)
  build(deps): bump golang.org/x/crypto from 0.31.0 to 0.35.0 in /_script (#910)
  Update author list
  fix(config): update default value of `maxConflicts` (#929)
  fix(profiling): sentence clarity (#928)
  feat(faq): add note with example about what can be synced (#922)
  chore(bep): update for TLS 1.3 (#924)
  feat(events): add information on X-Forwarded-For header (#907)
  chore(config): mention STUN SRV record (#904)
  Update author list
  fix(relay): document RelayFull message (fixes #880) (#909)
  feat(tuning): add section for LAN-only (fixes #834) (#915)
  fix(faq): update location of paths tab (#917)
  Update author list
  feat(faq): add information on setting network to private in Windows (#914)
  chore: remove option for enabling old TLS versions on sync connections (#913)
  chore(contrib): add sm2 and move munin-syncthing to unmaintained (#912)
  Update author list
  ...
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants