Skip to content

[WTEL-10851]security(fsvar): add FS variables validation helpers - #584

Draft
suifri wants to merge 3 commits into
mainfrom
security/WTEL-10851-fs-variables-injection
Draft

suifri wants to merge 3 commits into
mainfrom
security/WTEL-10851-fs-variables-injection

Conversation

@suifri

@suifri suifri commented Nov 6, 2026

Copy link
Copy Markdown
Contributor
  • add fsvar package to shared pkg
  • add variables validation helpers for both value and key
  • add quoting variable helper
  • add 100% unit-tests coverage of new helpers
  • add using of new helpers on make outbound call and set call variables
  • add set call variables ws method control validation for can update call right

@suifri
suifri requested a review from kirychukyurii November 6, 2026 14:03
- add fsvar package to shared pkg
- add variables validation helpers for both value and key
- add quoting variable helper
- add 100% unit-tests coverage of new helpers
- add using of new helpers on make outbound call and set call variables
- add set call variables ws method control validation for can update
  call right
@suifri
suifri force-pushed the security/WTEL-10851-fs-variables-injection branch from 3588a9d to 8efef8f Compare November 6, 2026 14:07
- add user input call variables validation on several endpoints (WS +
  GRPC)
- add additional call IDs validation on conroll app level
- add destination number validation
Comment thread wsapi/call.go Fixed
Comment thread wsapi/call.go Fixed
- add GetUsersCallsInfo application method that allow to get call info
  for two users in one call
- use wait group to sync two separate database calls to reduce time from
  O(n + m) to O(max(n, m))
@suifri
suifri force-pushed the security/WTEL-10851-fs-variables-injection branch from a25132d to 3d68af8 Compare November 6, 2026 16:35

@kirychukyurii kirychukyurii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

загалом, правки в wsapi (callBTDialplan, callInvite, callMute) давай окремим PR, бо в секюріті-фіксі вони заважають побачити, що саме змінилось, а його ще й бекпортити

і валідацію name/destination учасника черги (створення, редагування, імпорт) з WTEL-10853 тут не бачу - буде окремим PR?

Comment thread pkg/fsvar/fsvar.go
}
}

if strings.HasPrefix(l, "sip_") && !strings.HasPrefix(l, "sip_h_x-") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

денайлист завжди щось пропустить..
наші службові sip_h_X-Webitel-* зараз проходять, а їх має виставляти лише сервер

може краще все ж allowlist або обов'язковий usr_ для імен від клієнта?

Comment thread model/call.go
return err
}

if err := fsvar.ValidateNumber(r.Destination); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут номер ще сирий, а в inviteFromUser ми його все одно чистимо до [0-9+], тож +38 (067) 123-45-67 з контакту тепер впаде з 400, хоча раніше дзвонило
може перевіряти вже почищений номер, або для CreateCall це взагалі не треба?

Comment thread app/user.go
})

wg.Go(func() {
r, e := app.GetUserCallInfo(ctx, fromUserID, domainID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут же toUserID, бо зараз call_to_user дзвонить сам собі

але думаю, цей коміт краще взагалі винести окремим PR, бо до задачі він не стосується

Suggested change
r, e := app.GetUserCallInfo(ctx, fromUserID, domainID)
r, e := app.GetUserCallInfo(ctx, toUserID, domainID)

Comment thread go.mod
module github.com/webitel/engine

go 1.26.0
go 1.27.1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а чому?)

Comment thread controller/call.go
}

if uuid.Parse(fromId) == nil {
return "", model.NewBadRequestError("conttoller.call.bridge.from_id", fmt.Sprintf("from %q is not valid uuid format", fromId))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ рядком нижче

Suggested change
return "", model.NewBadRequestError("conttoller.call.bridge.from_id", fmt.Sprintf("from %q is not valid uuid format", fromId))
return "", model.NewBadRequestError("controller.call.bridge.from_id", fmt.Sprintf("from %q is not valid uuid format", fromId))

Comment thread wsapi/call.go
Comment on lines 581 to 589
for k, v := range variables {
switch v.(type) {
case string:
params.Variables[k] = v.(string)
case interface{}:
params.Variables[k] = fmt.Sprintf("%v", v)
if r, ok := v.(string); ok {
params.Variables[k] = r

continue
}

params.Variables[k] = fmt.Sprintf("%v", v)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

є ж parseWSInputVariable
+ те саме в callParams

Suggested change
for k, v := range variables {
switch v.(type) {
case string:
params.Variables[k] = v.(string)
case interface{}:
params.Variables[k] = fmt.Sprintf("%v", v)
if r, ok := v.(string); ok {
params.Variables[k] = r
continue
}
params.Variables[k] = fmt.Sprintf("%v", v)
}
for k, v := range variables {
params.Variables[k] = parseWSInputVariable(v)
}

@suifri

suifri commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

загалом, правки в wsapi (callBTDialplan, callInvite, callMute) давай окремим PR, бо в секюріті-фіксі вони заважають побачити, що саме змінилось, а його ще й бекпортити

і валідацію name/destination учасника черги (створення, редагування, імпорт) з WTEL-10853 тут не бачу - буде окремим PR?

це поки був більше дійсно драфтовий PR і я поки почав розбирати то на WS API, то не встиг усе розібрати, що по тасці було, бо я більше і більше там знаходив на рівні сокету...

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants