Accepting a BCB at one interaction point and sourcing a new BCB over the same target at a different interaction point deletes the bundle

Open
#398 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

@pablomadoery is already working on this.

Since Nov 25, 2026.

  • #399 by @pablomadoery — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c
Domain
backend, security

Research direction

Start with BSL_BundleRefState_RepopulateTgts and trace how it updates the bcb_tgts map when an acceptor removes a BCB result. Then inspect BSL_SecCtx_ValidatePolicyActionSet, which the issue identifies as treating an empty target entry as active. Done means a BCB accepted at CLIN can be replaced at CLOUT and the bundle is forwarded with only the new BCB; tests and a proposed fix are mentioned, and linked pull request #399 is already open.

Written by the indexing model from the issue text.

Description

Description

A policy that accepts a BCB over the payload at CLIN and sources a new BCB
over the payload at CLOUT cannot be applied. The intent is to re-encrypt the
payload while forwarding: decrypt it with the existing BCB when the bundle is
received, then encrypt it again under a new security source when it is sent.
Instead the bundle is deleted at CLOUT. The same happens with APPIN and APPOUT.

This is different from #396, where both operations are at the same interaction
point; the fix proposed for #396 (#397) does not cover this case.

Expected behavior

At CLIN the acceptor decrypts the payload and removes the BCB. At CLOUT the
source operation adds a new BCB over the payload, and the bundle is forwarded
with only the new BCB.

Actual behavior

The acceptor succeeds at CLIN, but at CLOUT validation still finds an existing
BCB over the payload, the action is skipped and the bundle is deleted with
reason code 0:

<INFO> [BCB_AES_GCM.c:108:BSLX_BCB_Decrypt] BCB attempting to decrypt
<INFO> [SamplePolicyProvider.c:467:BSLP_FinalizePolicy] PP FINALIZE: Sec Oper from action 0 at index 0: SUCCESS
<ERROR> [SecurityContext.c:818:BSL_SecCtx_ValidatePolicyActionSet] Cannot add service to target 1 that is already targeted by an existing BCB
<WARNING> [SecurityContext.c:661:BSL_SecCtx_ExecutePolicyActionSet] Skipping security action due to previous BSL validation failure
<INFO> [agent.c:445:MockBPA_DeleteBundle] MockBPA: BSL indicated to delete bundle with reason code 0

The first two lines are from CLIN, the rest from CLOUT.

The cause is in BSL_BundleRefState_RepopulateTgts. When the acceptor strips
the result for the payload, the reference to the BCB is removed from the
payload's entry in bcb_tgts, but the entry itself stays in the map with an
empty set. BSL_SecCtx_ValidatePolicyActionSet only checks whether the target
is present in the map (BSLB_AsbPtrSetMap_cget(...)), so the payload still
counts as a BCB target.

The same pattern with BIBs produces the expected output, because an existing
BIB over the target only causes a non-blocking warning for a BIB source.

Steps to reproduce

With bsl-mock-bpa built from main (ad0cb52), policy (keys from
mock-bpa-test/data/default-scs/keyset-1.json):

{
  "policyrule_set": [
    { "policyrule": {
        "filter": { "rule_id": "1", "role": "a", "tgt": 1, "loc": "clin", "sc_id": 2 },
        "spec": { "svc": "bcb", "sc_id": 2,
                  "sc_parms": { "key_name": "ExampleA.2", "key_wrap": true } },
        "policy_action_on_fail": "delete_bundle" } },
    { "policyrule": {
        "filter": { "rule_id": "2", "role": "s", "tgt": 1, "loc": "clout", "sc_id": 2 },
        "spec": { "svc": "bcb", "sc_id": 2,
                  "sc_parms": { "key_name": "ExampleA.2", "aes_variant": 1,
                                "aad_scope": 0, "key_wrap": true } },
        "policy_action_on_fail": "delete_bundle" } }
  ]
}

Send the RFC 9173 Appendix A.2 bundle (EXAMPLE_A_2_WITH_BCB in
mock-bpa-test/test_default_scs.py) from the underlayer. No bundle is
forwarded, and the log shows the lines above.

Environment
  • BSL main at ad0cb52 (also reproduced with v2.0.1)
  • Ubuntu 22.04, gcc 13.4, OpenSSL 3.0.2, Jansson 2.15.1
Proposed fix

I have a fix with tests and can open a pull request: in
BSL_BundleRefState_RepopulateTgts, remove target blocks that no security
block references any more, so that a block is only present in the target maps
while it is actually targeted.

Dominant language
C
Stars
16
Forks
11
Avg merge
8d 3h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NASA-AMMOS/BSL

All issues in NASA-AMMOS/BSL

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.